Java Code Examples for org.eclipse.swt.events.KeyEvent

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project swtbot, under directory /org.eclipse.swtbot.swt.finder.test/src/org/eclipse/swtbot/swt/finder/test/.

Source file: AbstractSWTShellTest.java

  21 
vote

public static String toKeyCode(int n,Widget widget){
  Event e=new Event();
  e.widget=widget;
  String toStringTreeEvent=new KeyEvent(e).toString();
  if (toStringTreeEvent.contains("keyCode=0x")) {
    return "0x" + Integer.toHexString(n);
  }
 else {
    return Integer.toString(n);
  }
}
 

Example 2

From project Archimedes, under directory /br.org.archimedes.core/src/br/org/archimedes/gui/swt/.

Source file: TextEditor.java

  19 
vote

private void createShell(){
  shell=new Shell(parent,SWT.DIALOG_TRIM);
  shell.setText(Messages.TextEditor_WindowName);
  shell.addDisposeListener(new DisposeListener(){
    public void widgetDisposed(    DisposeEvent arg0){
      getParent().setEnabled(true);
    }
  }
);
  shell.addKeyListener(new KeyAdapter(){
    public void keyReleased(    KeyEvent event){
      if (event.character == SWT.ESC) {
        shell.dispose();
      }
    }
  }
);
}
 

Example 3

From project bndtools, under directory /bndtools.core/src/bndtools/editor/common/.

Source file: TableViewerKeyBoardSupporter.java

  19 
vote

@Override public void keyPressed(KeyEvent e){
  if (e.stateMask == SWT.MOD1 || e.stateMask == SWT.MOD2) {
    if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.ARROW_DOWN) {
      fEditor.deactivate();
      e.doit=false;
      return;
    }
  }
  if (e.stateMask != SWT.NONE)   return;
switch (e.keyCode) {
case SWT.ARROW_DOWN:
    e.doit=false;
  int nextRow=fKeyBoardSupporter.getTable().getSelectionIndex() + 1;
if (nextRow >= fKeyBoardSupporter.getTable().getItemCount()) break;
fKeyBoardSupporter.getTable().setSelection(nextRow);
fKeyBoardSupporter.editColumnOrPrevPossible(fEditorColumn);
break;
case SWT.ARROW_UP:
e.doit=false;
int prevRow=fKeyBoardSupporter.getTable().getSelectionIndex() - 1;
if (prevRow < 0) break;
fKeyBoardSupporter.getTable().setSelection(prevRow);
fKeyBoardSupporter.editColumnOrPrevPossible(fEditorColumn);
break;
case SWT.F2:
e.doit=false;
fEditor.deactivate();
break;
default :
break;
}
}
 

Example 4

From project bpelunit, under directory /tycho/net.bpelunit.toolsupport/editors/formwidgets/.

Source file: FormEntry.java

  19 
vote

private void addListeners(){
  fText.addKeyListener(new KeyAdapter(){
    @Override public void keyReleased(    KeyEvent e){
      keyReleaseOccured(e);
    }
  }
);
  fText.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      editOccured(e);
    }
  }
);
  fText.addFocusListener(new FocusAdapter(){
    @Override public void focusGained(    FocusEvent e){
      if (fListener != null)       fListener.focusGained(FormEntry.this);
    }
    @Override public void focusLost(    FocusEvent e){
      if (fDirty)       commit();
    }
  }
);
}
 

Example 5

From project ccw, under directory /ccw.core/src/java/ccw/editors/clojure/.

Source file: ClojureSourceViewer.java

  19 
vote

public ClojureSourceViewer(Composite parent,IVerticalRuler verticalRuler,IOverviewRuler overviewRuler,boolean showAnnotationsOverview,int styles,IPreferenceStore store,IStatusLineHandler statusLineHandler){
  super(parent,verticalRuler,overviewRuler,showAnnotationsOverview,styles);
  setPreferenceStore(store);
  KeyListener escListener=new KeyListener(){
    public void keyPressed(    KeyEvent e){
      if (e.character == SWT.ESC) {
        if (!isContentAssistantActive) {
          inEscapeSequence=true;
          updateTabsToSpacesConverter();
          updateStructuralEditingModeStatusField();
        }
      }
    }
    public void keyReleased(    KeyEvent e){
      if (inEscapeSequence && !(e.character == SWT.ESC)) {
        inEscapeSequence=false;
        updateTabsToSpacesConverter();
        updateStructuralEditingModeStatusField();
      }
    }
  }
;
  addKeyListenerFirst(getTextWidget(),escListener);
  addTextInputListener(new ITextInputListener(){
    public void inputDocumentChanged(    IDocument oldInput,    IDocument newInput){
      if (newInput != null) {
        newInput.addDocumentListener(parseTreeConstructorDocumentListener);
        String text=newInput.get();
        updateTextBuffer(text,0,-1,text);
      }
    }
    public void inputDocumentAboutToBeChanged(    IDocument oldInput,    IDocument newInput){
      if (oldInput != null)       oldInput.removeDocumentListener(parseTreeConstructorDocumentListener);
    }
  }
);
  useStrictStructuralEditing=store.getBoolean(ccw.preferences.PreferenceConstants.USE_STRICT_STRUCTURAL_EDITING_MODE_BY_DEFAULT);
  isShowRainbowParens=store.getBoolean(ccw.preferences.PreferenceConstants.SHOW_RAINBOW_PARENS_BY_DEFAULT);
  this.statusLineHandler=statusLineHandler;
}
 

Example 6

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: CodePopup.java

  19 
vote

@Override public void keyPressed(KeyEvent e){
  if (e.character == 0x1B)   dispose();
  if (e.character == 'p' && (e.stateMask & SWT.MOD1) != 0) {
    e.doit=false;
    dispose();
    gotoNode(referencedNode,editor.getParseController().getProject(),editor.getParseController().getTypeChecker());
  }
}
 

Example 7

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.datamanager/src/org/cishell/reference/gui/datamanager/.

Source file: AbstractDataManagerView.java

  19 
vote

private void handleInput(){
  Control oldEditor=this.editor.getEditor();
  if (oldEditor != null) {
    oldEditor.dispose();
  }
  TreeItem[] selection=this.tree.getSelection();
  if (selection.length != 1) {
    return;
  }
  final TreeItem item=selection[0];
  if (item == null) {
    return;
  }
  this.newEditor=new Text(this.tree,SWT.NONE);
  this.newEditor.setText(item.getText());
  this.newEditor.addFocusListener(new FocusAdapter(){
    public void focusLost(    FocusEvent e){
      if (!updatingTreeItem) {
        AbstractDataManagerView.this.manager.setLabel(((DataGUIItem)item.getData()).getModel(),AbstractDataManagerView.this.newEditor.getText());
      }
    }
  }
);
  this.newEditor.addKeyListener(new KeyAdapter(){
    public void keyReleased(    KeyEvent e){
      if ((e.character == SWT.CR) && !AbstractDataManagerView.this.updatingTreeItem) {
        updateText(AbstractDataManagerView.this.newEditor.getText(),item);
      }
 else       if (e.keyCode == SWT.ESC) {
        AbstractDataManagerView.this.newEditor.dispose();
      }
    }
  }
);
  this.newEditor.selectAll();
  this.newEditor.setFocus();
  this.editor.setEditor(this.newEditor,item);
}
 

Example 8

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.entityrelation.edit/src-gen/org/obeonetwork/dsl/entityrelation/parts/impl/.

Source file: AttributePropertiesEditionPartImpl.java

  19 
vote

protected Composite createNameText(Composite parent){
  createDescription(parent,EntityrelationViewsRepository.Attribute.Properties.name,EntityrelationMessages.AttributePropertiesEditionPart_NameLabel);
  name=SWTUtils.createScrollableText(parent,SWT.BORDER);
  GridData nameData=new GridData(GridData.FILL_HORIZONTAL);
  name.setLayoutData(nameData);
  name.addFocusListener(new FocusAdapter(){
    /** 
 * {@inheritDoc}
 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
 */
    @Override @SuppressWarnings("synthetic-access") public void focusLost(    FocusEvent e){
      if (propertiesEditionComponent != null)       propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AttributePropertiesEditionPartImpl.this,EntityrelationViewsRepository.Attribute.Properties.name,PropertiesEditionEvent.COMMIT,PropertiesEditionEvent.SET,null,name.getText()));
    }
  }
);
  name.addKeyListener(new KeyAdapter(){
    /** 
 * {@inheritDoc}
 * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
 */
    @Override @SuppressWarnings("synthetic-access") public void keyPressed(    KeyEvent e){
      if (e.character == SWT.CR) {
        if (propertiesEditionComponent != null)         propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(AttributePropertiesEditionPartImpl.this,EntityrelationViewsRepository.Attribute.Properties.name,PropertiesEditionEvent.COMMIT,PropertiesEditionEvent.SET,null,name.getText()));
      }
    }
  }
);
  EditingUtils.setID(name,EntityrelationViewsRepository.Attribute.Properties.name);
  EditingUtils.setEEFtype(name,"eef::Text");
  SWTUtils.createHelpButton(parent,propertiesEditionComponent.getHelpContent(EntityrelationViewsRepository.Attribute.Properties.name,EntityrelationViewsRepository.SWT_KIND),null);
  return parent;
}
 

Example 9

From project dawn-common, under directory /org.dawb.common.ui/src/org/dawb/common/ui/components/cell/.

Source file: ScaleCellEditor.java

  19 
vote

@Override protected Control createControl(Composite parent){
  scale=new Scale(parent,getStyle());
  scale.setFont(parent.getFont());
  this.focusListener=new FocusAdapter(){
    @Override public void focusLost(    FocusEvent e){
      ScaleCellEditor.this.focusLost();
    }
  }
;
  if ((getStyle() & SWT.NO_FOCUS) == 0) {
    scale.addFocusListener(focusListener);
  }
  this.keyListener=new KeyListener(){
    @Override public void keyPressed(    KeyEvent e){
    }
    @Override public void keyReleased(    KeyEvent e){
      if (e.character == '\n') {
        ScaleCellEditor.this.focusLost();
      }
      if (e.character == '\r') {
        ScaleCellEditor.this.focusLost();
      }
    }
  }
;
  scale.addKeyListener(keyListener);
  return scale;
}
 

Example 10

From project dawn-isenciaui, under directory /com.isencia.passerelle.workbench.model.editor.ui/src/main/java/com/isencia/passerelle/workbench/model/editor/ui/cell/.

Source file: CComboCellEditor.java

  19 
vote

@Override protected Control createControl(Composite parent){
  comboBox=new CCombo(parent,getStyle());
  comboBox.setFont(parent.getFont());
  populateComboBoxItems();
  comboBox.addKeyListener(new KeyAdapter(){
    @Override public void keyPressed(    KeyEvent e){
      keyReleaseOccured(e);
    }
  }
);
  comboBox.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetDefaultSelected(    SelectionEvent event){
    }
    @Override public void widgetSelected(    SelectionEvent event){
      selection=comboBox.getSelectionIndex();
    }
  }
);
  comboBox.addTraverseListener(new TraverseListener(){
    @Override public void keyTraversed(    TraverseEvent e){
      if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
        e.doit=false;
      }
    }
  }
);
  comboBox.addFocusListener(new FocusAdapter(){
    @Override public void focusLost(    FocusEvent e){
      CComboCellEditor.this.focusLost();
    }
  }
);
  return comboBox;
}
 

Example 11

From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/system/.

Source file: LightWeightPlottingSystem.java

  19 
vote

private KeyListener getKeyListener(){
  if (keyListener == null)   keyListener=new KeyAdapter(){
    @Override public void keyPressed(    KeyEvent e){
      if (e.keyCode == 16777230 || e.character == 'h') {
        final IContributionItem action=bars.getToolBarManager().find("org.dawb.workbench.plotting.histo");
        if (action != null && action.isVisible() && action instanceof ActionContributionItem) {
          ActionContributionItem iaction=(ActionContributionItem)action;
          iaction.getAction().setChecked(!iaction.getAction().isChecked());
          iaction.getAction().run();
        }
      }
 else       if (e.keyCode == 16777217) {
        Point point=Display.getDefault().getCursorLocation();
        point.y-=1;
        Display.getDefault().setCursorLocation(point);
      }
 else       if (e.keyCode == 16777218) {
        Point point=Display.getDefault().getCursorLocation();
        point.y+=1;
        Display.getDefault().setCursorLocation(point);
      }
 else       if (e.keyCode == 16777219) {
        Point point=Display.getDefault().getCursorLocation();
        point.x-=1;
        Display.getDefault().setCursorLocation(point);
      }
      if (e.keyCode == 16777220) {
        Point point=Display.getDefault().getCursorLocation();
        point.x+=1;
        Display.getDefault().setCursorLocation(point);
      }
    }
  }
;
  return keyListener;
}
 

Example 12

From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/persistence/ui/internal/.

Source file: FiltersComposite.java

  19 
vote

@Override public void keyReleased(KeyEvent e){
  if (e.character == '\n' && (FilterSettings.isValidFilterString(text.getText()) < 0)) {
    String[] input=(String[])viewer.getInput();
    TreeSet<String> newInput=new TreeSet<String>(Arrays.asList(input));
    newInput.add(text.getText());
    viewer.setInput(newInput.toArray(new String[newInput.size()]));
  }
}
 

Example 13

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/.

Source file: MilestoneConstraintDialog.java

  19 
vote

private Control createTextualEditor(Composite parent){
  constraintViewer=new SourceViewer(parent,null,SWT.BORDER);
  constraintViewer.configure(new DRLSourceViewerConfig(null){
    public IReconciler getReconciler(    ISourceViewer sourceViewer){
      return null;
    }
    public IContentAssistant getContentAssistant(    ISourceViewer sourceViewer){
      ContentAssistant assistant=new ContentAssistant();
      completionProcessor=new ConstraintCompletionProcessor(process);
      assistant.setContentAssistProcessor(completionProcessor,IDocument.DEFAULT_CONTENT_TYPE);
      assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
      return assistant;
    }
  }
);
  String value=(String)getValue();
  if (value == null) {
    value="";
  }
  IDocument document=new Document(value);
  constraintViewer.setDocument(document);
  IDocumentPartitioner partitioner=new FastPartitioner(new DRLPartionScanner(),DRLPartionScanner.LEGAL_CONTENT_TYPES);
  partitioner.connect(document);
  document.setDocumentPartitioner(partitioner);
  constraintViewer.getControl().addKeyListener(new KeyListener(){
    public void keyPressed(    KeyEvent e){
      if (e.character == ' ' && e.stateMask == SWT.CTRL) {
        constraintViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
      }
    }
    public void keyReleased(    KeyEvent e){
    }
  }
);
  return constraintViewer.getControl();
}
 

Example 14

From project eclipse-instasearch, under directory /instasearch/src/it/unibz/instasearch/ui/.

Source file: InstaSearchView.java

  19 
vote

private void configureResultViewer(ResultContentProvider contentProvider,IBaseLabelProvider decoratedLabelProvider){
  resultViewer.setContentProvider(contentProvider);
  resultViewer.setLabelProvider(decoratedLabelProvider);
  resultViewer.setSorter(null);
  getViewSite().setSelectionProvider(resultViewer);
  resultViewer.addTreeListener(this);
  resultViewer.getControl().addMouseTrackListener(new MouseTrackAdapter(){
    public void mouseHover(    MouseEvent e){
      ViewerCell cell=resultViewer.getCell(new Point(e.x,e.y));
      if (cell != null && cell.getElement() instanceof SearchResultDoc) {
        SearchResultDoc doc=(SearchResultDoc)cell.getElement();
        resultViewer.getTree().setToolTipText(doc.getFilePath());
      }
 else {
        resultViewer.getTree().setToolTipText("");
      }
    }
  }
);
  KeyAdapter keyListener=new KeyAdapter(){
    public void keyReleased(    KeyEvent e){
      onSearchTextKeyPress(e);
    }
  }
;
  resultViewer.getControl().addKeyListener(keyListener);
  searchText.addKeyListener(keyListener);
}
 

Example 15

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.frameworks.ui/src/org/springsource/ide/eclipse/commons/frameworks/ui/internal/swt/.

Source file: ViewerSearchPart.java

  19 
vote

/** 
 * Adds the text control to the given composite. Must not be null.
 * @param parent Cannot be null
 */
protected void addPart(Composite parent){
  searchText=new Text(parent,SWT.SEARCH | SWT.ICON_CANCEL | SWT.ICON_SEARCH);
  searchText.setBackground(null);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(true,false).applyTo(searchText);
  searchText.addKeyListener(new KeyListener(){
    public void keyReleased(    KeyEvent event){
      handleSearch(searchText.getText());
    }
    public void keyPressed(    KeyEvent event){
    }
  }
);
  searchText.addSelectionListener(new SelectionAdapter(){
    public void widgetDefaultSelected(    SelectionEvent e){
      if (e.detail == SWT.CANCEL) {
        String searchString=searchText.getText();
        handleSearch(searchString);
      }
    }
  }
);
  searchText.setMessage("Type pattern to match");
}
 

Example 16

From project eclipse.platform.runtime, under directory /bundles/org.eclipse.core.tools/src/org/eclipse/core/tools/runtime/.

Source file: PluginDependencyView.java

  19 
vote

/** 
 * @see IWorkbenchPart#createPartControl
 */
public void createPartControl(Composite parent){
  viewer=new TextViewer(parent,SWT.V_SCROLL | SWT.H_SCROLL | SWT.WRAP| SWT.READ_ONLY);
  viewer.setDocument(new Document());
  IActionBars bars=getViewSite().getActionBars();
  final GlobalAction clearOutputAction=new ClearTextAction(viewer.getDocument());
  clearOutputAction.registerAsGlobalAction(bars);
  final GlobalAction selectAllAction=new SelectAllAction(viewer);
  selectAllAction.registerAsGlobalAction(bars);
  this.viewer.getControl().addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      if (e.character == SWT.DEL)       clearOutputAction.run();
    }
  }
);
  GlobalAction copyAction=new CopyTextSelectionAction(viewer);
  copyAction.registerAsGlobalAction(bars);
  bars.getToolBarManager().add(clearOutputAction);
  bars.updateActionBars();
  MenuManager menuMgr=new MenuManager();
  menuMgr.add(copyAction);
  menuMgr.add(clearOutputAction);
  Menu menu=menuMgr.createContextMenu(viewer.getControl());
  viewer.getControl().setMenu(menu);
  getViewSite().getPage().addSelectionListener(this);
}
 

Example 17

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/editors/cabal/forms/.

Source file: FormEntry.java

  19 
vote

private void keyReleaseOccured(final KeyEvent evt){
  if (evt.character == '\r') {
    if (dirty) {
      commit();
    }
  }
 else   if (evt.character == '\u001b') {
    if (!value.equals(textField.getText())) {
      textField.setText(value != null ? value : "");
    }
    dirty=false;
  }
  if (formEntryListener != null) {
    formEntryListener.selectionChanged(FormEntry.this);
  }
}
 

Example 18

From project EMF-IncQuery, under directory /plugins/org.eclipse.viatra2.emf.incquery.tooling.gui/src/org/eclipse/viatra2/emf/incquery/gui/wizards/internal/.

Source file: ElementSelectionDialog.java

  19 
vote

protected Text createFilterText(Composite parent){
  Text text=new Text(parent,SWT.BORDER);
  GridData data=new GridData();
  data.grabExcessVerticalSpace=false;
  data.grabExcessHorizontalSpace=true;
  data.horizontalAlignment=GridData.FILL;
  data.verticalAlignment=GridData.BEGINNING;
  text.setLayoutData(data);
  text.setFont(parent.getFont());
  text.setText((filter == null ? "" : filter));
  Listener listener=new Listener(){
    public void handleEvent(    Event e){
      importFilter.filterString=filterText.getText();
      tableViewer.refresh();
    }
  }
;
  text.addListener(SWT.Modify,listener);
  text.addKeyListener(new KeyListener(){
    public void keyPressed(    KeyEvent e){
      if (e.keyCode == SWT.ARROW_DOWN) {
        tableViewer.getTable().setFocus();
      }
    }
    public void keyReleased(    KeyEvent e){
    }
  }
);
  filterText=text;
  return text;
}
 

Example 19

From project Foglyn, under directory /com.foglyn.ui/src/com/foglyn/ui/.

Source file: AbstractEditorWithHint.java

  19 
vote

void installListeners(final Text text){
  text.addFocusListener(new FocusAdapter(){
    @Override public void focusGained(    FocusEvent e){
      text.getDisplay().timerExec(FOCUS_HINT_DELAY,enableHintRunnable);
    }
    @Override public void focusLost(    FocusEvent e){
      text.getDisplay().timerExec(-1,enableHintRunnable);
      hideDecorationHint();
    }
  }
);
  text.addKeyListener(new KeyAdapter(){
    @Override public void keyPressed(    KeyEvent e){
      if (e.character > 0) {
        hideDecorationHint();
      }
    }
    @Override public void keyReleased(    KeyEvent e){
      if (e.character == SWT.ESC) {
        text.getDisplay().timerExec(-1,enableHintRunnable);
      }
 else {
        text.getDisplay().timerExec(TYPING_HINT_DELAY,enableHintRunnable);
      }
    }
  }
);
  text.addModifyListener(new ModifyListener(){
    public void modifyText(    ModifyEvent e){
      processCurrentValue();
    }
  }
);
}
 

Example 20

From project gda-common-rcp, under directory /uk.ac.gda.common.rcp/src/uk/ac/gda/richbeans/components/cell/.

Source file: CComboCellEditor.java

  19 
vote

@Override protected Control createControl(Composite parent){
  comboBox=new CCombo(parent,getStyle());
  comboBox.setFont(parent.getFont());
  populateComboBoxItems();
  comboBox.addKeyListener(new KeyAdapter(){
    @Override public void keyPressed(    KeyEvent e){
      keyReleaseOccured(e);
    }
  }
);
  comboBox.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetDefaultSelected(    SelectionEvent event){
      applyEditorValueAndDeactivate();
    }
    @Override public void widgetSelected(    SelectionEvent event){
      selection=comboBox.getSelectionIndex();
      applyEditorValueAndDeactivate();
    }
  }
);
  comboBox.addTraverseListener(new TraverseListener(){
    @Override public void keyTraversed(    TraverseEvent e){
      if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
        e.doit=false;
      }
    }
  }
);
  comboBox.addFocusListener(new FocusAdapter(){
    @Override public void focusLost(    FocusEvent e){
      CComboCellEditor.this.focusLost();
    }
  }
);
  return comboBox;
}
 

Example 21

From project gmc, under directory /src/org.gluster.storage.management.console/src/org/gluster/storage/management/console/dialogs/.

Source file: BricksSelectionPage.java

  19 
vote

private void createFilter(final Text filterText,boolean caseSensitive){
  final String initialFilterString=filterText.getText();
  final EntityViewerFilter filter=new EntityViewerFilter(initialFilterString,caseSensitive);
  filterText.addKeyListener(new KeyAdapter(){
    private String filterString=initialFilterString;
    @Override public void keyReleased(    KeyEvent e){
      String enteredString=filterText.getText();
      if (enteredString.equals(filterString)) {
        return;
      }
      filterString=enteredString;
      filter.setFilterString(filterString);
      dualTableViewer.refreshAvailableViewer();
      dualTableViewer.refreshChosenViewer();
    }
  }
);
  dualTableViewer.setAvailableViewerFilter(filter);
  dualTableViewer.setChosenViewerFilter(filter);
}
 

Example 22

From project iee, under directory /org.eclipse.iee.sample.matrix/src/org/eclipse/iee/sample/matrix/pad/view/.

Source file: MatrixView.java

  19 
vote

public void createKeyListeners(Composite parent){
  parent.addKeyListener(new KeyListener(){
    @Override public void keyPressed(    KeyEvent e){
switch (e.keyCode) {
case SWT.ARROW_LEFT:
        System.out.println("LEFT");
      break;
case SWT.ARROW_RIGHT:
    System.out.println("RIGHT");
  break;
case SWT.ARROW_UP:
System.out.println("UP");
break;
case SWT.ARROW_DOWN:
System.out.println("DOWN");
break;
}
}
@Override public void keyReleased(KeyEvent arg0){
}
}
);
}
 

Example 23

From project incubator, under directory /net.karlmartens.ui/src/net/karlmartens/ui/viewer/.

Source file: CalendarComboCellEditor.java

  19 
vote

protected Control createControl(Composite parent){
  _control=new CalendarCombo(parent,getStyle());
  _control.setFont(parent.getFont());
  _control.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent e){
      keyReleaseOccured(e);
    }
  }
);
  _control.addSelectionListener(new SelectionAdapter(){
    public void widgetDefaultSelected(    SelectionEvent event){
      applyEditorValueAndDeactivate();
    }
    public void widgetSelected(    SelectionEvent event){
      _selection=_control.getText();
    }
  }
);
  _control.addTraverseListener(new TraverseListener(){
    public void keyTraversed(    TraverseEvent e){
      if (e.detail == SWT.TRAVERSE_ESCAPE || e.detail == SWT.TRAVERSE_RETURN) {
        e.doit=false;
      }
    }
  }
);
  _control.addFocusListener(new FocusAdapter(){
    public void focusLost(    FocusEvent e){
      CalendarComboCellEditor.this.focusLost();
    }
  }
);
  return _control;
}
 

Example 24

From project js4emf, under directory /org.eclipse.emf.js4emf.ui/src/org/eclipse/emf/js4emf/ui/.

Source file: ScriptScrapbookView.java

  19 
vote

public void createPartControl(Composite parent){
  super.createPartControl(parent);
  SashForm sash=new SashForm(parent,SWT.VERTICAL);
  scriptTextControl=createTextControl(sash,SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
  evalResultControl=createTextControl(sash,SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
  evalResultControl.setEditable(false);
  evalResultControl.setBackground(scriptTextControl.getBackground());
  sash.setWeights(new int[]{70,30});
  scriptTextControl.addKeyListener(new KeyAdapter(){
    public void keyReleased(    KeyEvent e){
      if (e.keyCode == 13 && e.stateMask == SWT.MOD1) {
        evalScript(getScriptControlText(true),false);
      }
    }
  }
);
}
 

Example 25

From project mousefeed, under directory /com.mousefeed/src/com/mousefeed/eclipse/preferences/.

Source file: ActionInvocationModeControl.java

  19 
vote

/** 
 * Constructor.
 * @param parent the container where to create the UI.Not <code>null</code>.
 */
public ActionInvocationModeControl(final Composite parent){
  super(parent,SWT.NONE);
  this.setLayout(new FormLayout());
  table=createTable(null);
  tableViewer=createTableViewer();
  resizeTableColumns();
  table.addKeyListener(new KeyAdapter(){
    @Override public void keyPressed(    final KeyEvent e){
      if (e.character == SWT.DEL && e.stateMask == 0) {
        removeSelected();
        e.doit=false;
      }
    }
  }
);
  tableViewer.addSelectionChangedListener(new ISelectionChangedListener(){
    public void selectionChanged(    final SelectionChangedEvent event){
      onTableSelectionChanged();
    }
  }
);
  removeButton=createRemoveButton();
  layoutTable(removeButton);
  createAddReminder(removeButton);
  onTableSelectionChanged();
}
 

Example 26

From project mylyn.context, under directory /org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/.

Source file: BrowseFilteredListener.java

  19 
vote

public void keyReleased(KeyEvent event){
  InterestFilter filter=getInterestFilter(viewer);
  if (event.keyCode == SWT.ARROW_RIGHT) {
    if (filter == null || !(viewer instanceof TreeViewer)) {
      return;
    }
    final TreeViewer treeViewer=(TreeViewer)viewer;
    ISelection selection=treeViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
      Object targetObject=((IStructuredSelection)selection).getFirstElement();
      unfilter(filter,treeViewer,targetObject);
    }
  }
}
 

Example 27

From project mylyn.docs.intent.main, under directory /plugins/org.eclipse.mylyn.docs.intent.client.ui/src/org/eclipse/mylyn/docs/intent/client/ui/editor/outline/.

Source file: IntentQuickOutlineControl.java

  19 
vote

/** 
 * Returns the KeyAdapter which will toggle the QuickOutline mode each time the right keySequence is pressed.
 * @return the KeyAdapter which will toggle the QuickOutline mode each time the right keySequence ispressed
 */
private KeyAdapter getKeyAdapterForToggling(){
  if (togglingKeyAdapter == null) {
    togglingKeyAdapter=new KeyAdapter(){
      public void keyPressed(      KeyEvent e){
        int accelerator=SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
        KeySequence keySequence=KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
        try {
          KeySequence expectedKeySequence=KeySequence.getInstance(KEY_SEQUENCE_FOR_TOGGLING);
          if (expectedKeySequence.equals(keySequence)) {
            toggleQuickOutlineMode();
          }
        }
 catch (        ParseException e1) {
        }
      }
    }
;
  }
  return togglingKeyAdapter;
}
 

Example 28

From project mylyn.incubator, under directory /org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/views/.

Source file: ActiveSearchQuickView.java

  19 
vote

private Text createFilterText(Composite parent){
  filterText=new Text(parent,SWT.NONE);
  GridData data=new GridData(GridData.FILL_HORIZONTAL);
  GC gc=new GC(parent);
  gc.setFont(parent.getFont());
  FontMetrics fontMetrics=gc.getFontMetrics();
  gc.dispose();
  data.heightHint=Dialog.convertHeightInCharsToPixels(fontMetrics,1);
  data.horizontalAlignment=GridData.FILL;
  data.verticalAlignment=GridData.CENTER;
  filterText.setLayoutData(data);
  filterText.addKeyListener(new KeyListener(){
    public void keyPressed(    KeyEvent e){
      if (e.keyCode == 0x0D) {
        gotoSelectedElement();
      }
      if (e.keyCode == SWT.ARROW_DOWN) {
        viewer.getTree().setFocus();
      }
      if (e.keyCode == SWT.ARROW_UP) {
        viewer.getTree().setFocus();
      }
      if (e.character == 0x1B) {
        dispose();
      }
    }
    public void keyReleased(    KeyEvent e){
    }
  }
);
  return filterText;
}
 

Example 29

From project netifera, under directory /platform/com.netifera.platform.ui/com.netifera.platform.ui/src/com/netifera/platform/ui/util/.

Source file: MouseTracker.java

  19 
vote

/** 
 * KeyListener methods 
 */
public void keyPressed(KeyEvent e){
  if (e.character == ' ') {
    Rectangle itemArea=getAreaOfSelectedItem();
    if (itemArea != null) {
      Point eventPoint=new Point(itemArea.x,itemArea.y);
      showEventAt(eventPoint);
    }
  }
 else   if (e.character == SWT.ESC) {
    hideInformationControl();
    ignoreShowEvents=false;
  }
 else {
    if (!isComputing) {
      e.doit=!focusInformationControl();
    }
  }
}
 

Example 30

From project org.openscada.orilla, under directory /org.openscada.ae.ui.views/src/org/openscada/ae/ui/views/dialog/.

Source file: FilterAdvancedComposite.java

  19 
vote

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;
}
 

Example 31

From project phing-eclipse, under directory /org.ganoro.phing.ui/src/org/ganoro/phing/ui/editors/.

Source file: AntSourceViewerInformationControl.java

  19 
vote

public AntSourceViewerInformationControl(Shell parent){
  GridLayout layout;
  GridData gd;
  fShell=new Shell(parent,SWT.ON_TOP | SWT.TOOL);
  Display display=fShell.getDisplay();
  fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
  Composite composite=fShell;
  layout=new GridLayout(1,false);
  layout.marginHeight=0;
  layout.marginWidth=0;
  composite.setLayout(layout);
  gd=new GridData(GridData.FILL_HORIZONTAL);
  composite.setLayoutData(gd);
  fViewer=createViewer(composite);
  fText=fViewer.getTextWidget();
  gd=new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
  fText.setLayoutData(gd);
  fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
  fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
  fText.addKeyListener(new KeyListener(){
    public void keyPressed(    KeyEvent e){
      if (e.character == 0x1B)       fShell.dispose();
    }
    public void keyReleased(    KeyEvent e){
    }
  }
);
}
 

Example 32

From project radrails, under directory /plugins/org.radrails.server.ui/src/org/radrails/server/internal/ui/console/.

Source file: ServerConsolePageParticipant.java

  19 
vote

public void init(IPageBookViewPage page,IConsole console){
  if (!(console instanceof org.eclipse.debug.ui.console.IConsole))   return;
  org.eclipse.debug.ui.console.IConsole processConsole=(org.eclipse.debug.ui.console.IConsole)console;
  final IProcess process=processConsole.getProcess();
  if (!looksLikeServerStarting(process)) {
    return;
  }
  this.consoleStopAction=new ServerStopAction(process);
  this.launchBrowserAction=new LaunchBrowserAction(process);
  IActionBars bars=page.getSite().getActionBars();
  toolbar=bars.getToolBarManager();
  removeTerminateAction(toolbar);
  bars.getToolBarManager().prependToGroup(IConsoleConstants.LAUNCH_GROUP,consoleStopAction);
  bars.getToolBarManager().prependToGroup(IConsoleConstants.LAUNCH_GROUP,launchBrowserAction);
  TextConsolePage consolePage=(TextConsolePage)page;
  consolePage.getControl().addKeyListener(new KeyListener(){
    public void keyReleased(    KeyEvent e){
    }
    public void keyPressed(    KeyEvent e){
      int keyCode=e.keyCode;
      if (keyCode == 'c' && e.stateMask == SWT.CONTROL) {
        consoleStopAction.run();
      }
    }
  }
);
}
 

Example 33

From project rap-osgi-tutorial-ece2011, under directory /com.codeaffine.example.rwt.osgi.configurationadmin/src/com/codeaffine/example/rwt/osgi/configurationadmin/console/.

Source file: CommandParser.java

  19 
vote

public void keyReleased(KeyEvent event){
  if (enterPressed(event)) {
    inputProcessor.processCommand();
  }
  consoleWidget.getParent().layout(true,true);
}
 

Example 34

From project recommenders, under directory /plugins/org.eclipse.recommenders.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/rcp/.

Source file: SearchBox.java

  19 
vote

@Override public void keyPressed(KeyEvent e){
  if (e.keyCode == SWT.ARROW_UP) {
    resultDisplayTableSelection(resultDisplayTable,-1);
  }
  if (e.keyCode == SWT.ARROW_DOWN) {
    resultDisplayTableSelection(resultDisplayTable,1);
  }
}
 

Example 35

From project samolisov-demo, under directory /Eclipse/RCP/Hyperbola/org.rcpbook.hyperbola.ui/src/org/rcpbook/hyperbola/ui/editors/.

Source file: ChatEditor.java

  19 
vote

@Override public void createPartControl(Composite parent){
  Composite top=new Composite(parent,SWT.NONE);
  GridLayout layout=new GridLayout();
  layout.marginWidth=0;
  layout.marginHeight=0;
  top.setLayout(layout);
  transcript=new Text(top,SWT.BORDER | SWT.MULTI | SWT.WRAP);
  transcript.setLayoutData(new GridData(GridData.FILL,GridData.FILL,true,true));
  transcript.setEditable(false);
  transcript.setBackground(transcript.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
  transcript.setForeground(transcript.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
  entry=new Text(top,SWT.BORDER | SWT.WRAP);
  GridData gridData=new GridData(GridData.FILL,GridData.FILL,true,false);
  gridData.heightHint=entry.getLineHeight() * 2;
  entry.setLayoutData(gridData);
  entry.addKeyListener(new KeyAdapter(){
    public void keyPressed(    KeyEvent event){
      if (event.character == SWT.CR) {
        sendMessage();
        event.doit=false;
      }
    }
  }
);
  messageListener=new MessageListener(){
    public void processMessage(    Chat chat,    Message message){
      process(message);
    }
  }
;
  getChat().addMessageListener(messageListener);
}
 

Example 36

From project savara-tools-eclipse, under directory /plugins/org.savara.tools.scenario/src/main/java/org/savara/tools/scenario/designer/view/.

Source file: FileURLCellEditor.java

  19 
vote

/** 
 * Processes a key release event that occurred in this cell editor. <p> The <code>TextCellEditor</code> implementation of this framework method  ignores when the RETURN key is pressed since this is handled in  <code>handleDefaultSelection</code>. An exception is made for Ctrl+Enter for multi-line texts, since a default selection event is not sent in this case.  </p>
 * @param keyEvent the key event
 */
protected void keyReleaseOccured(KeyEvent keyEvent){
  if (keyEvent.character == '\r') {
    if (m_textField != null && !m_textField.isDisposed() && (m_textField.getStyle() & SWT.MULTI) != 0) {
      if ((keyEvent.stateMask & SWT.CTRL) != 0) {
        super.keyReleaseOccured(keyEvent);
      }
    }
    return;
  }
  super.keyReleaseOccured(keyEvent);
}
 

Example 37

From project scisoft-icat, under directory /uk.ac.diamond.scisoft.icatexplorer.rcp/src/uk/ac/diamond/scisoft/icatexplorer/rcp/wizards/.

Source file: ICATWizardPage.java

  19 
vote

@Override public void keyReleased(KeyEvent e){
  if (e.getSource().equals(txtProject)) {
    dialogChanged();
  }
  if (e.getSource().equals(txtFedid)) {
    dialogChanged();
  }
  if (e.getSource().equals(txtPassword)) {
    dialogChanged();
  }
  if (e.getSource().equals(txtSftpServer)) {
    dialogChanged();
  }
  if (e.getSource().equals(txtTruststorePassword)) {
    dialogChanged();
  }
}
 

Example 38

From project scisoft-ui, under directory /uk.ac.diamond.scisoft.analysis.rcp/src/uk/ac/diamond/scisoft/analysis/rcp/imagegrid/.

Source file: SWTImageGrid.java

  19 
vote

@Override public void keyReleased(KeyEvent e){
  if (e.character == 'v' || e.character == 'V') {
    visualizeCache=!visualizeCache;
    canvas.redraw();
  }
  if (e.character == 'o' || e.character == 'O') {
    overviewWindow=!overviewWindow;
    canvas.redraw();
  }
}
 

Example 39

From project TadpoleForDBTools, under directory /com.hangum.db.browser.rap.core/src/com/hangum/tadpole/rdb/core/editors/intro/.

Source file: IntroEditor.java

  19 
vote

@Override public void createPartControl(Composite parent){
  parent.setLayout(new GridLayout(1,false));
  Composite compositeHead=new Composite(parent,SWT.NONE);
  compositeHead.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false,1,1));
  GridLayout gl_compositeHead=new GridLayout(3,false);
  gl_compositeHead.verticalSpacing=2;
  gl_compositeHead.horizontalSpacing=2;
  gl_compositeHead.marginWidth=2;
  compositeHead.setLayout(gl_compositeHead);
  Label lblUrl=new Label(compositeHead,SWT.NONE);
  lblUrl.setLayoutData(new GridData(SWT.RIGHT,SWT.CENTER,false,false,1,1));
  lblUrl.setText("URL  ");
  textURL=new Text(compositeHead,SWT.BORDER);
  textURL.addKeyListener(new KeyAdapter(){
    @Override public void keyReleased(    KeyEvent e){
      if (e.keyCode == SWT.Selection) {
        setBrowserURL(textURL.getText());
      }
    }
  }
);
  textURL.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false,1,1));
  textURL.setText(GetPreferenceGeneral.getDefaultHomePage());
  Button btnGo=new Button(compositeHead,SWT.NONE);
  btnGo.addSelectionListener(new SelectionAdapter(){
    @Override public void widgetSelected(    SelectionEvent e){
      setBrowserURL(textURL.getText());
    }
  }
);
  btnGo.setText("go");
  Composite composite=new Composite(parent,SWT.BORDER);
  composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,1,1));
  composite.setLayout(new GridLayout(1,false));
  browser=new Browser(composite,SWT.NONE);
  browser.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,1,1));
  logger.debug("home page : " + GetPreferenceGeneral.getDefaultHomePage());
  setBrowserURL(GetPreferenceGeneral.getDefaultHomePage());
}
 

Example 40

From project trademaker, under directory /src/org/lifeform/gui/.

Source file: CompletionEditor.java

  19 
vote

private void buildControls(){
  setLayout(new FillLayout());
  textViewer=new TextViewer(this,SWT.MULTI | SWT.V_SCROLL);
  textViewer.getControl().addKeyListener(new KeyAdapter(){
    public void keyPressed(    final KeyEvent e){
    }
  }
);
  textViewer.addTextListener(new ITextListener(){
    public void textChanged(    final TextEvent e){
      if (isWhitespaceString(e.getText())) {
        wordTracker.add(findMostRecentWord(e.getOffset() - 1));
      }
    }
  }
);
}
 

Example 41

From project Utah-Tools-Decision-Support, under directory /applicationGeneric/edu.utah.generic.application/src/edu/utah/generic/application/splashHandlers/.

Source file: InteractiveSplashHandler.java

  19 
vote

/** 
 */
private void createUITextPassword(){
  int style=SWT.PASSWORD | SWT.BORDER;
  fTextPassword=new Text(fCompositeLogin,style);
  GridData data=new GridData(SWT.NONE,SWT.NONE,false,false);
  data.widthHint=F_TEXT_WIDTH_HINT;
  data.horizontalSpan=2;
  fTextPassword.setLayoutData(data);
  fTextPassword.addKeyListener(new KeyAdapter(){
    public void keyReleased(    KeyEvent e){
      if (fTextUsername.getText().length() > 1 && fTextPassword.getText().length() > 1) {
        fCompositeLogin.getShell().setDefaultButton(fButtonOK);
      }
    }
  }
);
}
 

Example 42

From project warlock2, under directory /core/cc.warlock.rcp/src/cc/warlock/rcp/ui/.

Source file: ContentAssistCellEditor.java

  19 
vote

/** 
 * Processes a key release event that occurred in this cell editor. The implementation of this framework method  ignores when the RETURN key is pressed since this is handled in  handleDefaultSelection. An exception is made for Ctrl+Enter for multi-line texts, since a default selection event is not sent in this case. 
 * @param keyEvent the key event
 */
protected void keyReleaseOccured(KeyEvent keyEvent){
  if (keyEvent.character == '\r') {
    if (text != null && !text.isDisposed() && (text.getStyle() & SWT.MULTI) != 0) {
      if ((keyEvent.stateMask & SWT.CTRL) != 0) {
        super.keyReleaseOccured(keyEvent);
      }
    }
    return;
  }
  super.keyReleaseOccured(keyEvent);
}
 

Example 43

From project zest, under directory /org.eclipse.zest.examples/src/org/eclipse/zest/examples/layouts/.

Source file: ContainerResizeGraphSnippet.java

  19 
vote

/** 
 * @param args
 */
public static void main(String[] args){
  Display d=new Display();
  image1=new Image(Display.getDefault(),ContainerResizeGraphSnippet.class.getResourceAsStream("package_obj.gif"));
  classImage=new Image(Display.getDefault(),ContainerResizeGraphSnippet.class.getResourceAsStream("class_obj.gif"));
  Shell shell=new Shell(d);
  shell.setText("GraphSnippet1");
  shell.setLayout(new FillLayout());
  shell.setSize(500,800);
  final Graph g=new Graph(shell,SWT.NONE);
  createContainer(g);
  CompositeLayoutAlgorithm compositeLayoutAlgorithm=new CompositeLayoutAlgorithm(new LayoutAlgorithm[]{new GridLayoutAlgorithm(),new HorizontalShiftAlgorithm()});
  g.setLayoutAlgorithm(compositeLayoutAlgorithm,true);
  g.addKeyListener(new KeyListener(){
    boolean flip=true;
    public void keyPressed(    KeyEvent e){
      if (g.getSelection().size() == 1) {
        GraphNode item=(GraphNode)g.getSelection().get(0);
        if (item.getItemType() == GraphItem.CONTAINER) {
          if (flip) {
            (item).setSize(500,100);
          }
 else {
            (item).setSize(0,0);
          }
          flip=!flip;
        }
      }
    }
    public void keyReleased(    KeyEvent e){
    }
  }
);
  shell.open();
  while (!shell.isDisposed()) {
    while (!d.readAndDispatch()) {
      d.sleep();
    }
  }
  image1.dispose();
}