From a6445f282e01f997369d54f1641bb043c703509e Mon Sep 17 00:00:00 2001 From: Evgeny Pasynkov Date: Wed, 4 Jul 2012 15:16:39 +0200 Subject: [PATCH] Move ModalityStateEx to core-impl --- .../application/impl/ModalityStateEx.java | 204 +++++++++--------- 1 file changed, 102 insertions(+), 102 deletions(-) rename platform/{platform-impl => core-impl}/src/com/intellij/openapi/application/impl/ModalityStateEx.java (96%) diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java b/platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java similarity index 96% rename from platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java rename to platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java index 682475183590..e45934aa5196 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java +++ b/platform/core-impl/src/com/intellij/openapi/application/impl/ModalityStateEx.java @@ -1,102 +1,102 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.application.impl; - -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.progress.ProgressIndicator; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.lang.ref.WeakReference; -import java.util.ArrayList; - -public class ModalityStateEx extends ModalityState { - private static final WeakReference[] EMPTY_REFS_ARRAY = new WeakReference[0]; - - private final WeakReference[] myModalEntities; - - public ModalityStateEx() { - this(EMPTY_REFS_ARRAY); - } - - public ModalityStateEx(@NotNull Object[] modalEntities) { - if (modalEntities.length > 0) { - myModalEntities = new WeakReference[modalEntities.length]; - for (int i = 0; i < modalEntities.length; i++) { - Object entity = modalEntities[i]; - myModalEntities[i] = new WeakReference(entity); - } - } - else{ - myModalEntities = EMPTY_REFS_ARRAY; - } - } - - @NotNull - public ModalityState appendProgress(@NotNull ProgressIndicator progress){ - return appendEntity(progress); - } - - @NotNull - ModalityStateEx appendEntity(@NotNull Object anEntity){ - ArrayList list = new ArrayList(); - for (WeakReference modalEntity : myModalEntities) { - Object entity = modalEntity.get(); - if (entity == null) continue; - list.add(entity); - } - list.add(anEntity); - return new ModalityStateEx(list.toArray()); - } - - private static boolean contains(WeakReference[] array, Object o){ - for (WeakReference reference : array) { - Object o1 = reference.get(); - if (o1 == null) continue; - if (o1.equals(o)) return true; - } - return false; - } - - @Override - public boolean dominates(@NotNull ModalityState anotherState){ - if (anotherState == ModalityState.any()) return false; - - for (WeakReference modalEntity : myModalEntities) { - Object entity = modalEntity.get(); - if (entity == null) continue; - if (!contains(((ModalityStateEx)anotherState).myModalEntities, entity)) return true; // I have entity which is absent in anotherState - } - return false; - } - - boolean contains(Object modalEntity) { - return contains(myModalEntities, modalEntity); - } - - @NonNls - public String toString() { - if (myModalEntities.length == 0) return "ModalityState.NON_MODAL"; - @NonNls StringBuilder buffer = new StringBuilder(); - buffer.append("ModalityState:"); - for (int i = 0; i < myModalEntities.length; i++) { - Object entity = myModalEntities[i].get(); - if (i > 0) buffer.append(", "); - buffer.append(entity); - } - return buffer.toString(); - } -} +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.application.impl; + +import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.progress.ProgressIndicator; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +public class ModalityStateEx extends ModalityState { + private static final WeakReference[] EMPTY_REFS_ARRAY = new WeakReference[0]; + + private final WeakReference[] myModalEntities; + + public ModalityStateEx() { + this(EMPTY_REFS_ARRAY); + } + + public ModalityStateEx(@NotNull Object[] modalEntities) { + if (modalEntities.length > 0) { + myModalEntities = new WeakReference[modalEntities.length]; + for (int i = 0; i < modalEntities.length; i++) { + Object entity = modalEntities[i]; + myModalEntities[i] = new WeakReference(entity); + } + } + else{ + myModalEntities = EMPTY_REFS_ARRAY; + } + } + + @NotNull + public ModalityState appendProgress(@NotNull ProgressIndicator progress){ + return appendEntity(progress); + } + + @NotNull + ModalityStateEx appendEntity(@NotNull Object anEntity){ + ArrayList list = new ArrayList(); + for (WeakReference modalEntity : myModalEntities) { + Object entity = modalEntity.get(); + if (entity == null) continue; + list.add(entity); + } + list.add(anEntity); + return new ModalityStateEx(list.toArray()); + } + + private static boolean contains(WeakReference[] array, Object o){ + for (WeakReference reference : array) { + Object o1 = reference.get(); + if (o1 == null) continue; + if (o1.equals(o)) return true; + } + return false; + } + + @Override + public boolean dominates(@NotNull ModalityState anotherState){ + if (anotherState == ModalityState.any()) return false; + + for (WeakReference modalEntity : myModalEntities) { + Object entity = modalEntity.get(); + if (entity == null) continue; + if (!contains(((ModalityStateEx)anotherState).myModalEntities, entity)) return true; // I have entity which is absent in anotherState + } + return false; + } + + boolean contains(Object modalEntity) { + return contains(myModalEntities, modalEntity); + } + + @NonNls + public String toString() { + if (myModalEntities.length == 0) return "ModalityState.NON_MODAL"; + @NonNls StringBuilder buffer = new StringBuilder(); + buffer.append("ModalityState:"); + for (int i = 0; i < myModalEntities.length; i++) { + Object entity = myModalEntities[i].get(); + if (i > 0) buffer.append(", "); + buffer.append(entity); + } + return buffer.toString(); + } +}