2 * Copyright 2000-2009 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
.wm
.impl
;
18 import com
.intellij
.openapi
.diagnostic
.Logger
;
19 import com
.intellij
.openapi
.wm
.ToolWindowAnchor
;
21 import java
.util
.Iterator
;
22 import java
.util
.Stack
;
25 * This is stack of tool window that were replaced by another tool windows.
27 * @author Vladimir Kondratyev
29 final class SideStack
{
30 private static final Logger LOG
= Logger
.getInstance("#com.intellij.openapi.wm.impl.SideStack");
31 private final Stack myStack
;
34 myStack
= new Stack();
38 * Pushes <code>info</code> into the stack. The method stores cloned copy of original <code>info</code>.
40 void push(final WindowInfoImpl info
) {
41 LOG
.assertTrue(info
.isDocked());
42 LOG
.assertTrue(!info
.isAutoHide());
43 myStack
.push(info
.copy());
46 WindowInfoImpl
pop(final ToolWindowAnchor anchor
) {
47 for (int i
= myStack
.size() - 1; true; i
--) {
48 final WindowInfoImpl info
= (WindowInfoImpl
)myStack
.get(i
);
49 if (anchor
== info
.getAnchor()) {
57 * @return <code>true</code> if and only if there is window in the state with the same
58 * <code>anchor</code> as the specified <code>info</code>.
60 boolean isEmpty(final ToolWindowAnchor anchor
) {
61 for (int i
= myStack
.size() - 1; i
> -1; i
--) {
62 final WindowInfoImpl info
= (WindowInfoImpl
)myStack
.get(i
);
63 if (anchor
== info
.getAnchor()) {
71 * Removes all <code>WindowInfo</code>s with the specified <code>id</code>.
73 void remove(final String id
) {
74 for (Iterator i
= myStack
.iterator(); i
.hasNext();) {
75 final WindowInfoImpl info
= (WindowInfoImpl
)i
.next();
76 if (id
.equals(info
.getId())) {