本文整理汇总了Java中com.intellij.util.IJSwingUtilities.hasFocus方法的典型用法代码示例。如果您正苦于以下问题:Java IJSwingUtilities.hasFocus方法的具体用法?Java IJSwingUtilities.hasFocus怎么用?Java IJSwingUtilities.hasFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.IJSwingUtilities
的用法示例。
在下文中一共展示了IJSwingUtilities.hasFocus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshIntentionHint
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
public void refreshIntentionHint() {
if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){
hideIntentionHint();
return;
}
if (myHint == null || !myHint.isVisible()) {
updateIntentionHintVisibility();
}
else {
final ErrorInfo[] errorInfos = getErrorInfos();
final Rectangle bounds = getErrorBounds();
if (!haveFixes(errorInfos) || bounds == null || !bounds.equals(myLastHintBounds)) {
hideIntentionHint();
updateIntentionHintVisibility();
}
}
}
示例2: showSelectedColumnProperties
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private boolean showSelectedColumnProperties() {
if (myCustomPropertiesPanel != null && myPropertiesPanelContainer != null &&
IJSwingUtilities.hasFocus(myCustomPropertiesPanel.getComponent())) {
return true;
}
if (myEditor == null) return false;
GridCaptionPanel panel = myEditor.getFocusedCaptionPanel();
if (panel == null) return false;
RadContainer container = panel.getSelectedContainer();
if (container == null) return false;
final int[] selection = panel.getSelectedCells(null);
myPropertiesPanelContainer = container;
final CustomPropertiesPanel propertiesPanel = container.getGridLayoutManager().getRowColumnPropertiesPanel(container, panel.isRow(), selection);
if (propertiesPanel == null) return false;
showCustomPropertiesPanel(propertiesPanel);
return true;
}
示例3: positionCaretToDeclaration
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
protected static void positionCaretToDeclaration(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiElement declaration) {
final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null && (IJSwingUtilities.hasFocus(editor.getComponent()) || ApplicationManager.getApplication().isUnitTestMode())) {
final PsiFile openedFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (openedFile == psiFile) {
editor.getCaretModel().moveToOffset(declaration.getTextOffset());
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
}
}
示例4: isFocusOwner
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
@Override
public boolean isFocusOwner() {
if (myEditor != null) {
return IJSwingUtilities.hasFocus(myEditor.getContentComponent());
}
return super.isFocusOwner();
}
示例5: showIntentionHint
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
/**
* Shows intention hint (light bulb) if it's not visible yet.
*/
final void showIntentionHint(){
if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){
hideIntentionHint();
return;
}
// 1. Hide previous hint (if any)
hideIntentionHint();
// 2. Found error (if any)
final ErrorInfo[] errorInfos = getErrorInfos();
if(!haveFixes(errorInfos)) {
hideIntentionHint();
return;
}
// 3. Determine position where this hint should be shown
final Rectangle bounds = getErrorBounds();
if(bounds == null){
return;
}
// 4. Show light bulb to fix this error
final LightBulbComponentImpl lightBulbComponent = new LightBulbComponentImpl(this, AllIcons.Actions.IntentionBulb);
myHint = new LightweightHint(lightBulbComponent);
myLastHintBounds = bounds;
myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
示例6: update
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
public void update() {
if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) {
hideHint();
}
else if (myHint == null || !myHint.isVisible()) {
updateHintVisibility();
}
else {
Rectangle bounds = getErrorBounds();
if (!ErrorInfo.haveFixes(getErrorInfos()) || bounds == null || !bounds.equals(myLastHintBounds)) {
hideHint();
updateHintVisibility();
}
}
}
示例7: showHint
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private void showHint() {
if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) {
hideHint();
return;
}
// 1. Hide previous hint (if any)
hideHint();
// 2. Found error (if any)
List<ErrorInfo> infos = getErrorInfos();
if (!ErrorInfo.haveFixes(infos)) {
hideHint();
return;
}
boolean error = false;
for (ErrorInfo errorInfo : infos) {
if (errorInfo.getLevel() == HighlightDisplayLevel.ERROR) {
error = true;
break;
}
}
// 3. Determine position where this hint should be shown
Rectangle bounds = getErrorBounds();
if (bounds == null) {
return;
}
// 4. Show light bulb to fix this error
myHint = new LightweightHint(new InspectionHint(error ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb));
myLastHintBounds = bounds;
myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
示例8: moveCaretTo
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private static void moveCaretTo(final PsiElement newCaretPosition) {
Project project = newCaretPosition.getProject();
final PsiFile psiFile = newCaretPosition.getContainingFile();
final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
if (editor != null && IJSwingUtilities.hasFocus(editor.getComponent())) {
final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (file == psiFile) {
editor.getCaretModel().moveToOffset(newCaretPosition.getTextRange().getEndOffset());
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
}
}
示例9: updateCaretCursor
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
void updateCaretCursor() {
if (!ourIsUnitTestMode && !IJSwingUtilities.hasFocus(getContentComponent())) {
stopOptimizedScrolling();
}
myUpdateCursor = true;
}
示例10: MyState
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
public MyState() {
isFocused = IJSwingUtilities.hasFocus(getFocusableComponent());
}
示例11: selectElementAtCaretNotLosingFocus
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private void selectElementAtCaretNotLosingFocus(@NotNull Editor editor) {
if (IJSwingUtilities.hasFocus(getCurrentProjectViewPane().getComponentToFocus())) return;
selectElementAtCaret(editor);
}
示例12: selectElementAtCaretNotLosingFocus
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private void selectElementAtCaretNotLosingFocus() {
if (IJSwingUtilities.hasFocus(this.getComponentToFocus())) return;
scrollFromSource();
}
示例13: isPaintSelection
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
public boolean isPaintSelection() {
return myPaintSelection || !isOneLineMode() || IJSwingUtilities.hasFocus(getContentComponent());
}
示例14: paint
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private void paint(@NotNull Graphics g) {
if (!isEnabled() || !myIsShown || !IJSwingUtilities.hasFocus(getContentComponent()) || isRendererMode()) return;
int x = myLocation.x;
int lineHeight = getLineHeight();
int y = myLocation.y;
Rectangle viewRectangle = getScrollingModel().getVisibleArea();
if (x - viewRectangle.x < 0) {
return;
}
g.setColor(myScheme.getColor(EditorColors.CARET_COLOR));
if (!paintBlockCaret()) {
if (UIUtil.isRetina()) {
g.fillRect(x, y, mySettings.getLineCursorWidth(), lineHeight);
} else {
for (int i = 0; i < mySettings.getLineCursorWidth(); i++) {
UIUtil.drawLine(g, x + i, y, x + i, y + lineHeight - 1);
}
}
}
else {
Color caretColor = myScheme.getColor(EditorColors.CARET_COLOR);
if (caretColor == null) caretColor = new JBColor(Color.BLACK, Color.WHITE);
g.setColor(caretColor);
g.fillRect(x, y, myWidth, lineHeight - 1);
final LogicalPosition startPosition = getCaretModel().getLogicalPosition();
final int offset = logicalPositionToOffset(startPosition);
char[] chars = myDocument.getRawChars();
if (chars.length > offset) {
FoldRegion folding = myFoldingModel.getCollapsedRegionAtOffset(offset);
final char ch;
if (folding == null || folding.isExpanded()) {
ch = chars[offset];
}
else {
VisualPosition visual = getCaretModel().getVisualPosition();
VisualPosition foldingPosition = offsetToVisualPosition(folding.getStartOffset());
if (visual.line == foldingPosition.line) {
ch = folding.getPlaceholderText().charAt(visual.column - foldingPosition.column);
}
else {
ch = chars[offset];
}
}
IterationState state = null;
try {
//don't worry it's cheap. Cache is not required
state = new IterationState(EditorImpl.this, offset, offset + 1, true);
TextAttributes attributes = state.getMergedAttributes();
if (attributes != null) {
FontInfo info = EditorUtil.fontForChar(ch, attributes.getFontType(), EditorImpl.this);
if (info != null) {
g.setFont(info.getFont());
}
}
//todo[kb]
//in case of italic style we paint out of the cursor block. Painting the symbol to a dedicated buffered image
//solves the problem, but still looks weird because it leaves colored pixels at right.
g.setColor(CURSOR_FOREGROUND);
g.drawChars(new char[]{ch}, 0, 1, x, y + getAscent());
}
finally {
if (state != null) state.dispose();
}
}
}
}
示例15: selectElementAtCaretNotLosingFocus
import com.intellij.util.IJSwingUtilities; //导入方法依赖的package包/类
private void selectElementAtCaretNotLosingFocus(final Editor editor) {
if (IJSwingUtilities.hasFocus(getCurrentProjectViewPane().getComponentToFocus())) return;
selectElementAtCaret(editor);
}