Package org.eclipse.swt.events

Examples of org.eclipse.swt.events.FocusListener


    public TXmlMultiLineText(Node n, Text t) {
      text = t;
      masterNode = n;
      LoadText();
      text.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
          SaveText();
        }
View Full Code Here


            value = "0";
          }
          int level = Integer.parseInt(value);
          spinner.setSelection(level);
          spinner.setFocus();
          spinner.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
            }

            public void focusLost(FocusEvent e) {
              // Clean up any previous editor control
              Control oldEditor = editor1.getEditor();
              if (oldEditor != null)
                oldEditor.dispose();

              oldEditor = editor2.getEditor();
              if (oldEditor != null)
                oldEditor.dispose();
              spinner.dispose();
            }

          });
          spinner.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
              int selection = spinner.getSelection();
              item.setText(1, Integer.toString(selection));
              int id = nvp.getId();
              if (obj instanceof GetMetadataErrors) {
                GetMetadataErrors getMetadataErrors = (GetMetadataErrors) obj;
                getMetadataErrors.setValueById(id, selection);
                getMetaDataViewer.refresh();

              } else if (obj instanceof ProcessCasErrors) {
                ProcessCasErrors processCasErrors = (ProcessCasErrors) obj;
                processCasErrors.setValueById(id, selection);
                processCasErrorsViewer.refresh();

              } else if (obj instanceof CollectionProcessCompleteErrors) {
                CollectionProcessCompleteErrors completeErrors = (CollectionProcessCompleteErrors) obj;
                completeErrors.setValueById(id, selection);
                collProcessCompleteErrorsViewer.refresh();
              }
              multiPageEditor.setFileDirty();
            }
          });
          editor1.setEditor(spinner, item, 1);

        } else if (nvp.getType() == String.class) {
          final CCombo combo = new CCombo(table, SWT.BORDER | SWT.READ_ONLY);
          combo.setItems(new String[] { "terminate", "disable" }); //$NON-NLS-1$
          combo.setText(item.getText(1));
          combo.pack();
          combo.setFocus();
          combo.addFocusListener(new FocusListener() {

            public void focusGained(FocusEvent e) {
            }

            public void focusLost(FocusEvent e) {
              // Clean up any previous editor control
              Control oldEditor = editor1.getEditor();
              if (oldEditor != null)
                oldEditor.dispose();

              oldEditor = editor2.getEditor();
              if (oldEditor != null)
                oldEditor.dispose();
              combo.dispose();
            }

          });
          combo.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              String selection = combo.getText();
              item.setText(1, selection);
              int id = nvp.getId();
              if (obj instanceof GetMetadataErrors) {
                GetMetadataErrors getMetadataErrors = (GetMetadataErrors) obj;
                getMetadataErrors.setValueById(id, selection);
                getMetaDataViewer.refresh();

              } else if (obj instanceof ProcessCasErrors) {
                ProcessCasErrors processCasErrors = (ProcessCasErrors) obj;
                processCasErrors.setValueById(id, selection);
                processCasErrorsViewer.refresh();

              } else if (obj instanceof CollectionProcessCompleteErrors) {
                CollectionProcessCompleteErrors completeErrors = (CollectionProcessCompleteErrors) obj;
                completeErrors.setValueById(id, selection);
                collProcessCompleteErrorsViewer.refresh();
              }
              multiPageEditor.setFileDirty();
            }
          });
          editor2.setEditor(combo, item, 1);

        } else if (nvp.getType() == Boolean.class) {
          // Only for ProcessCasErrors
          if (obj instanceof ProcessCasErrors) {
            final CCombo combo = new CCombo(table, SWT.BORDER | SWT.READ_ONLY);
            combo.setItems(new String[] { Boolean.toString(true), Boolean.toString(false) }); //$NON-NLS-1$
            combo.setText(item.getText(1));
            combo.pack();
            combo.setFocus();
            combo.addFocusListener(new FocusListener() {

              public void focusGained(FocusEvent e) {
              }

              public void focusLost(FocusEvent e) {
View Full Code Here

  public void onFirstShown() {
    String baseUrl = host.normalizeURL("/");
    setLocationText(baseUrl);
    location.setFocus();
    location.setSelection(baseUrl.length());
    location.addFocusListener(new FocusListener() {
      public void focusGained(FocusEvent e) {
        int length = location.getText().length();
        location.setSelection(length, length);
      }
View Full Code Here

        if (deck != null) {
          deck.set(DeckConstants.FEATURE_TOURNAMENT_LEGALITY, deckLegality.getText());
        }
      }
    });
    deckLegality.addFocusListener(new FocusListener() {
      public void focusGained(FocusEvent e) {
      }

      public void focusLost(FocusEvent e) {
        // Legality might have changed
View Full Code Here

            e.doit=false;
          }
        }
      });
     
      text.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
          setValue(text.getText());
        }
        @Override
View Full Code Here

    /**
     * Initialize actions for copy / paste functionality.
     */
    private void initCopyPasteActions() {
     
      tableViewer.getTable().addFocusListener(new FocusListener() {
            IAction standardDelete = editor.getEditorSite().getActionBars().getGlobalActionHandler(ActionFactory.DELETE.getId());
            IAction csvRowDelete = new Action() {
                public void run() {
                  if(tableViewer.getTable().getSelection().length > 0) {
                    TableItem currentSelectedRow = tableViewer.getTable().getSelection()[0];
                    if(currentSelectedRow != null) {
                CsvRow selectedRow = (CsvRow)currentSelectedRow.getData();
                csvTable.remove(selectedRow);
                refresh(RefreshMode.DATA);
                setDirty(true);
                    }
                  }
                }
            };    
           
            public void focusLost(FocusEvent e) {
              editor.getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.DELETE.getId(), standardDelete);
              editor.getEditorSite().getActionBars().updateActionBars();
            }
            public void focusGained(FocusEvent e) {
              editor.getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.DELETE.getId(), csvRowDelete);
              editor.getEditorSite().getActionBars().updateActionBars();
            }
        });
     
      tableViewer.getTable().addFocusListener(new FocusListener() {
            IAction standardCopy = editor.getEditorSite().getActionBars().getGlobalActionHandler(ActionFactory.COPY.getId());
            IAction csvRowCopy = new Action() {
                public void run() {
                  if(tableViewer.getTable().getSelection().length > 0) {
                    TableItem currentSelectedRow = tableViewer.getTable().getSelection()[0];
                    if(currentSelectedRow != null) {
                CsvRow selectedRow = (CsvRow)currentSelectedRow.getData();
                Clipboard clipboard = new Clipboard(getShell().getDisplay());
                clipboard.setContents(new Object[] { selectedRow }, new Transfer[] { new CsvRowTransfer()});
                    }
                  }
                }
            };

            public void focusLost(FocusEvent e) {
              editor.getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), standardCopy);
              editor.getEditorSite().getActionBars().updateActionBars();
            }

            public void focusGained(FocusEvent e) {
              editor.getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.COPY.getId(), csvRowCopy);
              editor.getEditorSite().getActionBars().updateActionBars();
            }
        });
     
      tableViewer.getTable().addFocusListener(new FocusListener() {
            IAction standardPaste = editor.getEditorSite().getActionBars().getGlobalActionHandler(ActionFactory.PASTE.getId());
            IAction csvRowPaste = new Action() {
                public void run() {
                    Clipboard clipboard = new Clipboard(getShell().getDisplay());
                    try {
                        CsvRow entity = (CsvRow)clipboard.getContents(new CsvRowTransfer());
                        if(tableViewer.getTable().getSelection().length > 0) {
                        TableItem currentSelectedRow = tableViewer.getTable().getSelection()[0];
                        if(currentSelectedRow != null) {
                    CsvRow selectedRow = (CsvRow)currentSelectedRow.getData();
                            drop(entity, selectedRow);
                        }
                      }
                    } finally {
                        clipboard.dispose();
                    }           
                }
            };       
           
            public void focusLost(FocusEvent e) {
              editor.getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.PASTE.getId(), standardPaste);
                editor.getEditorSite().getActionBars().updateActionBars();
            }
            public void focusGained(FocusEvent e) {
              editor.getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.PASTE.getId(), csvRowPaste);
              editor.getEditorSite().getActionBars().updateActionBars();
           
      });
     
      tableViewer.getTable().addFocusListener(new FocusListener() {
            IAction standardCut = editor.getEditorSite().getActionBars().getGlobalActionHandler(ActionFactory.CUT.getId());
            IAction csvRowCut = new Action() {
                public void run() {
                    Clipboard clipboard = new Clipboard(getShell().getDisplay());
                    if(tableViewer.getTable().getSelection().length > 0) {
View Full Code Here

    // _dataBindingContext.bindValue(SWTObservables.observeText(_elementTypeField),
    // BeansObservables.observeValue(_refactoringElement,
    // RefactoringElementModel.ELEMENT_TYPE),
    // elementTypeUpdateStrategy, null);
    _elementTypeField.addFocusListener(new FocusListener() {
      public void focusGained(FocusEvent e) {
        // DO NOTHING
      }

      public void focusLost(FocusEvent e) {
View Full Code Here

  @Override
  protected Control createControl(Composite parent) {
    final Text searchBox = new Text(parent, SWT.FILL | SWT.BORDER);

    TextUtils.setToDefault(searchBox, "{OpenGrok");
    searchBox.addFocusListener(new FocusListener() {

      @Override
      public void focusLost(FocusEvent e) {
        if (!disableFocusLostEvent) {
          TextUtils.setToDefault(searchBox, "{OpenGrok");
View Full Code Here

    filter = new Text(parent, SWT.FILL);
    filter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    TextUtils.setToDefault(filter, FILTER_DEFAULT);
    filter.addFocusListener(new FocusListener() {
      @Override
      public void focusLost(FocusEvent e) {
        if ("".equals(filter.getText())) {
          TextUtils.setToDefault(filter, FILTER_DEFAULT);
        }
View Full Code Here

        String preferenceKey = "txt_RegExp";
        txt_RegExp.addFocusListener(new SaveLastValueToPreferenceStoreFocusAdapter(preferenceStore, preferenceKey));
        txt_RegExp.setText(preferenceStore.getString(preferenceKey));
       
       
        txt_RegExp.addFocusListener(new FocusListener() {

            private int caretOffset;

            public void focusGained(FocusEvent e) {
                ((StyledText) e.widget).setCaretOffset(caretOffset);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.events.FocusListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.