2 * Copyright 2000-2010 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.openapi
.application
;
18 import com
.intellij
.util
.messages
.Topic
;
22 import java
.awt
.event
.InputEvent
;
23 import java
.awt
.event
.KeyEvent
;
24 import java
.awt
.event
.MouseEvent
;
26 public interface UserActivity
{
28 Topic
<UserActivity
> TOPIC
= Topic
.create("UserActivity", UserActivity
.class);
30 void onKeyboardActivity(KeyEvent e
);
31 void onMouseActivity(MouseEvent e
);
35 class Adapter
implements UserActivity
{
37 public void onKeyboardActivity(KeyEvent e
) {
40 public void onMouseActivity(MouseEvent e
) {
43 public void onIdle() {
49 public static boolean isEditorActivity(InputEvent e
) {
51 if (e
instanceof KeyEvent
) {
52 c
= KeyboardFocusManager
.getCurrentKeyboardFocusManager().getFocusOwner();
53 } else if (e
instanceof MouseEvent
) {
54 c
= SwingUtilities
.getDeepestComponentAt(e
.getComponent(), ((MouseEvent
)e
).getX(), ((MouseEvent
)e
).getY());
57 if (c
instanceof JComponent
) {
58 return Boolean
.TRUE
.equals(((JComponent
)c
).getClientProperty("isEditor"));