Пример #1
0
 public static CellEditor createPropertyEditor(
     final IServiceLocator serviceLocator,
     Composite parent,
     DBPPropertySource source,
     DBPPropertyDescriptor property) {
   if (source == null) {
     return null;
   }
   final Object object = source.getEditableValue();
   if (!property.isEditable(object)) {
     return null;
   }
   CellEditor cellEditor = UIUtils.createCellEditor(parent, object, property);
   if (cellEditor != null) {
     final Control editorControl = cellEditor.getControl();
     UIUtils.addFocusTracker(serviceLocator, UIUtils.INLINE_WIDGET_EDITOR_ID, editorControl);
     editorControl.addDisposeListener(
         new DisposeListener() {
           @Override
           public void widgetDisposed(DisposeEvent e) {
             UIUtils.removeFocusTracker(serviceLocator, editorControl);
           }
         });
   }
   return cellEditor;
 }
Пример #2
0
  public static void enableHostEditorKeyBindingsSupport(
      final IWorkbenchPartSite partSite, Control control) {
    if (!(partSite.getPart() instanceof AbstractTextEditor)) {
      return;
    }

    final boolean[] activated = new boolean[] {false};
    control.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            if (!activated[0]) {
              UIUtils.enableHostEditorKeyBindings(partSite, false);
              activated[0] = true;
            }
          }

          @Override
          public void focusLost(FocusEvent e) {
            if (activated[0]) {
              UIUtils.enableHostEditorKeyBindings(partSite, true);
              activated[0] = false;
            }
          }
        });
    control.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            if (activated[0]) {
              UIUtils.enableHostEditorKeyBindings(partSite, true);
              activated[0] = false;
            }
          }
        });
  }