Java 类com.intellij.openapi.editor.impl.EditorComponentImpl 实例源码

项目:intellij-ce-playground    文件:IdeFocusTraversalPolicy.java   
private static boolean _accept(final JComponent component) {
  if (!component.isEnabled() || !component.isVisible() || !component.isFocusable()) {
    return false;
  }

  /** TODO[anton,vova] implement Policy in Editor component instead */
  if (component instanceof EditorComponentImpl || component instanceof EditorWindowHolder) {
    return true;
  }

  if(component instanceof JTextComponent){
    return ((JTextComponent)component).isEditable();
  }

  return
    component instanceof AbstractButton ||
    component instanceof JList ||
    component instanceof JTree ||
    component instanceof JTable ||
    component instanceof JComboBox;
}
项目:intellij-ce-playground    文件:ToolWindowManagerImpl.java   
@Override
protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
  if (myWindowManager.getCommandProcessor().getCommandCount() > 0 || component == null) {
    return;
  }
  final KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
  final Component owner = mgr.getFocusOwner();

  if (owner instanceof EditorComponentImpl && cause instanceof FocusEvent) {
    JFrame frame = WindowManager.getInstance().getFrame(myProject);
    Component oppositeComponent = ((FocusEvent)cause).getOppositeComponent();
    if (oppositeComponent != null && UIUtil.getWindow(oppositeComponent) != frame) {
      return;
    }
  }

  IdeFocusManager.getInstance(myProject).doWhenFocusSettlesDown(new ExpirableRunnable.ForProject(myProject) {
    @Override
    public void run() {
      if (mgr.getFocusOwner() == owner) {
        activateEditorComponent(false);
      }
    }
  });
}
项目:intellij-ce-playground    文件:UpDownHandler.java   
@Override
public void update(AnActionEvent e) {
  final LookupEx lookup;
  if (myInput instanceof EditorTextField) {
    lookup = LookupManager.getActiveLookup(((EditorTextField)myInput).getEditor());
  } else if (myInput instanceof EditorComponentImpl) {
    lookup = LookupManager.getActiveLookup(((EditorComponentImpl)myInput).getEditor());
  } else {
    lookup = null;
  }

  JComboBox comboBox = UIUtil.findComponentOfType(myInput, JComboBox.class);
  boolean popupMenuVisible = comboBox != null && comboBox.isPopupVisible();

  e.getPresentation().setEnabled(lookup == null && !popupMenuVisible);
}
项目:tools-idea    文件:IdeFocusTraversalPolicy.java   
private static boolean _accept(final JComponent component) {
  if (!component.isEnabled() || !component.isVisible() || !component.isFocusable()) {
    return false;
  }

  /** TODO[anton,vova] implement Policy in Editor component instead */
  if (component instanceof EditorComponentImpl || component instanceof EditorWindowHolder) {
    return true;
  }

  if(component instanceof JTextComponent){
    return ((JTextComponent)component).isEditable();
  }

  return
    component instanceof AbstractButton ||
    component instanceof JList ||
    component instanceof JTree ||
    component instanceof JTable ||
    component instanceof JComboBox;
}
项目:consulo    文件:IdeFocusTraversalPolicy.java   
private static boolean _accept(final JComponent component) {
  if (!component.isEnabled() || !component.isVisible() || !component.isFocusable()) {
    return false;
  }

  /* TODO[anton,vova] implement Policy in Editor component instead */
  if (component instanceof EditorComponentImpl || component instanceof EditorWindowHolder) {
    return true;
  }

  if (component instanceof JTextComponent) {
    return ((JTextComponent)component).isEditable();
  }

  return component instanceof AbstractButton ||
         component instanceof JList ||
         component instanceof JTree ||
         component instanceof JTable ||
         component instanceof JComboBox;
}
项目:consulo    文件:DesktopToolWindowManagerImpl.java   
@Override
protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
  if (myCommandProcessor.getCommandCount() > 0 || component == null) {
    return;
  }
  final KeyboardFocusManager mgr = KeyboardFocusManager.getCurrentKeyboardFocusManager();
  final Component owner = mgr.getFocusOwner();

  if (owner instanceof EditorComponentImpl && cause instanceof FocusEvent) {
    JFrame frame = WindowManager.getInstance().getFrame(myProject);
    Component oppositeComponent = ((FocusEvent)cause).getOppositeComponent();
    if (oppositeComponent != null && UIUtil.getWindow(oppositeComponent) != frame) {
      return;
    }
  }

  IdeFocusManager.getInstance(myProject).doWhenFocusSettlesDown(new ExpirableRunnable.ForProject(myProject) {
    @Override
    public void run() {
      if (mgr.getFocusOwner() == owner) {
        activateEditorComponent();
      }
    }
  });
}
项目:intellij-ce-playground    文件:RenameTo.java   
@Nullable
private static Editor getEditorFromFocus() {
  final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (c instanceof EditorComponentImpl) {
    return ((EditorComponentImpl)c).getEditor();
  }
  return null;
}
项目:intellij-ce-playground    文件:FileEditorManagerImpl.java   
private static boolean moveFocusOnDelete() {
  final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
  if (window != null) {
    final Component component = FocusTrackback.getFocusFor(window);
    if (component != null) {
      return component instanceof EditorComponentImpl;
    }
    return window instanceof IdeFrameImpl;
  }
  return true;
}
项目:idea-multimarkdown    文件:TypoRenameToQuickFix.java   
@Nullable
private static Editor getEditorFromFocus() {
    final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    if (c instanceof EditorComponentImpl) {
        return ((EditorComponentImpl) c).getEditor();
    }
    return null;
}
项目:IDEOM    文件:WallPaper.java   
private Point calculate_position(Component component, int imageWidth, int imageHeight) {
    Point p = new Point();

    Rectangle rect = ((EditorComponentImpl) component).getVisibleRect();
    int position_x = 0;
    switch (this.editorSetting.imageHorizonPositionNo) {
        // 右に表示
        case 0:
            position_x = rect.x;
            break;
        // 中央に表示
        case 1:
            position_x = rect.x + (rect.width - imageWidth) / 2;
            break;
        // 左に表示
        case 2:
            position_x = rect.x + rect.width - imageWidth;
            break;
    }
    int position_y = 0;
    switch (this.editorSetting.imageVerticalPositionNo) {
        // 上に表示
        case 0:
            position_y = rect.y;
            break;
        // 中央に表示
        case 1:
            position_y = rect.y + (rect.height - imageHeight) / 2;
            break;
        // 下に表示
        case 2:
            position_y = rect.y + rect.height - imageHeight;
            break;
    }

    p.setLocation(position_x, position_y);

    return p;
}
项目:tools-idea    文件:RenameTo.java   
@Nullable
private static Editor getEditorFromFocus() {
  final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (c instanceof EditorComponentImpl) {
    return ((EditorComponentImpl)c).getEditor();
  }
  return null;
}
项目:tools-idea    文件:TestDataProvider.java   
@Override
public Object getData(@NonNls String dataId) {
  if (myProject.isDisposed()) {
    throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" +
                               "If you closed a project in test, please reset IdeaTestApplication.setDataProvider.");
  }

  if (PlatformDataKeys.PROJECT.is(dataId)) {
    return myProject;
  }
  else if (PlatformDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
    return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
  }
  else {
    Editor editor = (Editor)getData(PlatformDataKeys.EDITOR.getName());
    if (editor != null) {
      FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
      Object managerData = manager.getData(dataId, editor, manager.getSelectedFiles()[0]);
      if (managerData != null) {
        return managerData;
      }
      JComponent component = editor.getContentComponent();
      if (component instanceof EditorComponentImpl) {
        return ((EditorComponentImpl)component).getData(dataId);
      }
    }
    return null;
  }
}
项目:tools-idea    文件:FileEditorManagerImpl.java   
private static boolean moveFocusOnDelete() {
  final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
  if (window != null) {
    final Component component = FocusTrackback.getFocusFor(window);
    if (component != null) {
      return component instanceof EditorComponentImpl;
    }
    return window instanceof IdeFrameImpl;
  }
  return true;
}
项目:tools-idea    文件:UpDownHandler.java   
@Override
public void update(AnActionEvent e) {
  final LookupEx lookup;
  if (myInput instanceof EditorTextField) {
    lookup = LookupManager.getActiveLookup(((EditorTextField)myInput).getEditor());
  } else if (myInput instanceof EditorComponentImpl) {
    lookup = LookupManager.getActiveLookup(((EditorComponentImpl)myInput).getEditor());
  } else {
    lookup = null;
  }

  e.getPresentation().setEnabled(lookup == null);
}
项目:consulo    文件:TestDataProvider.java   
@Override
public Object getData(@Nonnull Key<?> dataId) {
  if (myProject.isDisposed()) {
    throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" +
                               "If you closed a project in test, please reset IdeaTestApplication.setDataProvider.");
  }

  if (CommonDataKeys.PROJECT == dataId) {
    return myProject;
  }
  else if (PlatformDataKeys.EDITOR == dataId || OpenFileDescriptor.NAVIGATE_IN_EDITOR == dataId) {
    return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
  }
  else {
    Editor editor = (Editor)getData(PlatformDataKeys.EDITOR);
    if (editor != null) {
      FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
      Object managerData = manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
      if (managerData != null) {
        return managerData;
      }
      JComponent component = editor.getContentComponent();
      if (component instanceof EditorComponentImpl) {
        return ((EditorComponentImpl)component).getData(dataId);
      }
    }
    return null;
  }
}
项目:consulo    文件:IdeBackgroundUtil.java   
private static String getComponentType(JComponent component) {
  return component instanceof JTree ? "tree" :
         component instanceof JList ? "list" :
         component instanceof JTable ? "table" :
         component instanceof JViewport ? "viewport" :
         component instanceof ActionToolbar ? "toolbar" :
         component instanceof EditorComponentImpl ? "editor" :
         component instanceof EditorGutterComponentEx ? "editor" :
         component instanceof JBLoadingPanel ? "loading" :
         component instanceof JBTabs ? "tabs" :
         component instanceof JBPanelWithEmptyText ? "panel" :
         component instanceof JPanel && ourKnownNames.contains(component.getName()) ? component.getName() :
         null;
}
项目:consulo    文件:UpDownHandler.java   
@Override
public void update(AnActionEvent e) {
  final LookupEx lookup;
  if (myInput instanceof EditorTextField) {
    lookup = LookupManager.getActiveLookup(((EditorTextField)myInput).getEditor());
  } else if (myInput instanceof EditorComponentImpl) {
    lookup = LookupManager.getActiveLookup(((EditorComponentImpl)myInput).getEditor());
  } else {
    lookup = null;
  }

  e.getPresentation().setEnabled(lookup == null);
}
项目:force-shortcuts-intellij-plugin    文件:ForceShortcuts.java   
private boolean isEditorComponent(Object source) {
    return source.getClass() == EditorComponentImpl.class;
}
项目:intellij-ce-playground    文件:AbstractValueHint.java   
protected boolean showHint(final JComponent component) {
  myInsideShow = true;
  if (myCurrentHint != null) {
    myCurrentHint.hide();
  }
  myCurrentHint = new LightweightHint(component) {
    @Override
    protected boolean canAutoHideOn(TooltipEvent event) {
      InputEvent inputEvent = event.getInputEvent();
      if (inputEvent instanceof MouseEvent) {
        Component comp = inputEvent.getComponent();
        if (comp instanceof EditorComponentImpl) {
          EditorImpl editor = ((EditorComponentImpl)comp).getEditor();
          return !isInsideCurrentRange(editor, ((MouseEvent)inputEvent).getPoint());
        }
      }
      return true;
    }
  };
  myCurrentHint.addHintListener(new HintListener() {
    @Override
    public void hintHidden(EventObject event) {
      if (myHideRunnable != null && !myInsideShow) {
        myHideRunnable.run();
      }
      onHintHidden();
    }
  });

  // editor may be disposed before later invokator process this action
  if (myEditor.isDisposed() || myEditor.getComponent().getRootPane() == null) {
    return false;
  }

  Point p = HintManagerImpl.getHintPosition(myCurrentHint, myEditor, myEditor.xyToLogicalPosition(myPoint), HintManager.UNDER);
  HintHint hint = HintManagerImpl.createHintHint(myEditor, p, myCurrentHint, HintManager.UNDER, true);
  hint.setShowImmediately(true);
  HintManagerImpl.getInstanceImpl().showEditorHint(myCurrentHint, myEditor, p,
                                                   HintManager.HIDE_BY_ANY_KEY |
                                                   HintManager.HIDE_BY_TEXT_CHANGE |
                                                   HintManager.HIDE_BY_SCROLLING, 0, false,
                                                   hint);
  myInsideShow = false;
  return true;
}