no quequ - alarms!!!!
[fedora-idea.git] / openapi / src / com / intellij / util / xml / ui / CommitablePanelUserActivityListener.java
blob0a82edbf5f412c4e133139653980788e22ac2d96
1 /*
2 * Copyright 2000-2006 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.
18 package com.intellij.util.xml.ui;
20 import com.intellij.ui.UserActivityListener;
21 import com.intellij.openapi.application.ApplicationManager;
22 import com.intellij.util.ui.update.MergingUpdateQueue;
23 import com.intellij.util.ui.update.Update;
24 import com.intellij.util.Alarm;
26 /**
27 * User: Sergey.Vasiliev
29 public class CommitablePanelUserActivityListener implements UserActivityListener {
30 private boolean myResetting;
32 CommittablePanel myPanel;
34 private Alarm myAlarm;
36 public CommitablePanelUserActivityListener() {
39 public CommitablePanelUserActivityListener(final CommittablePanel panel) {
40 myPanel = panel;
41 myAlarm = new Alarm();
44 final public void stateChanged() {
45 myAlarm.cancelAllRequests();
46 myAlarm.addRequest(new Runnable() {
47 public void run() {
48 doActivity();
50 }, 239);
54 protected void doActivity() {
55 if (!myResetting) {
56 ApplicationManager.getApplication().invokeLater(new Runnable() {
57 public void run() {
59 myResetting = true;
60 try {
61 applyChanges();
63 finally {
64 myResetting = false;
66 doAfterApply();
68 });
72 protected void applyChanges() {
73 if (myPanel != null) {
74 myPanel.commit();
78 protected void doAfterApply() {