helper method isEditorActivity

This commit is contained in:
Kirill Kalishev
2010-02-01 16:28:55 +03:00
parent 36400a07c6
commit ee119bd812
4 changed files with 30 additions and 0 deletions
@@ -344,6 +344,10 @@ public class AbstractTreeBuilder implements Disposable {
}
}
protected ProgressIndicator getProgressIndicator() {
return getUi().getProgressIndicator();
}
protected void updateAfterLoadedInBackground(Runnable runnable) {
if (myUi.isPassthroughMode()) {
runnable.run();
@@ -1784,6 +1784,10 @@ public class AbstractTreeUi {
return result;
}
public ProgressIndicator getProgressIndicator() {
return myProgress;
}
static class ElementNode extends DefaultMutableTreeNode {
Set<Object> myElements = new HashSet<Object>();
@@ -17,6 +17,9 @@ package com.intellij.openapi.application;
import com.intellij.util.messages.Topic;
import javax.swing.*;
import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
@@ -41,4 +44,22 @@ public interface UserActivity {
}
}
class Util {
public static boolean isEditorActivity(InputEvent e) {
Component c = null;
if (e instanceof KeyEvent) {
c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
} else if (e instanceof MouseEvent) {
c = SwingUtilities.getDeepestComponentAt(e.getComponent(), ((MouseEvent)e).getX(), ((MouseEvent)e).getY());
}
if (c instanceof JComponent) {
return Boolean.TRUE.equals(((JComponent)c).getClientProperty("isEditor"));
}
return false;
}
}
}
@@ -44,6 +44,7 @@ public class EditorComponentImpl extends JComponent implements Scrollable, DataP
enableInputMethods(true);
setFocusCycleRoot(true);
setOpaque(true);
putClientProperty("isEditor", Boolean.TRUE);
}
public EditorImpl getEditor() {