mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Notify folding listener about folding region removal
This commit is contained in:
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.editor.ex;
|
||||
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
@@ -27,17 +13,25 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface FoldingListener {
|
||||
|
||||
/**
|
||||
* Informs that {@code 'collapsed'} state of given fold region is just changed.
|
||||
* Informs that {@code 'collapsed'} state of given fold region is just changed, or that the given fold region has just been created.
|
||||
* <p/>
|
||||
* <b>Note:</b> listener should delay fold region state processing until {@link #onFoldProcessingEnd()} is called.
|
||||
* I.e. folding model may return inconsistent data between current moment and {@link #onFoldProcessingEnd()}.
|
||||
*
|
||||
* @param region fold region that is just collapsed or expanded
|
||||
*/
|
||||
void onFoldRegionStateChange(@NotNull FoldRegion region);
|
||||
default void onFoldRegionStateChange(@NotNull FoldRegion region) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs that the given fold region is about to be removed.
|
||||
*/
|
||||
default void beforeFoldRegionRemoved(@NotNull FoldRegion region) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Informs that fold processing is done.
|
||||
*/
|
||||
void onFoldProcessingEnd();
|
||||
default void onFoldProcessingEnd() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,6 +271,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
|
||||
|
||||
((FoldRegionImpl)region).setExpanded(true, false);
|
||||
notifyListenersOnFoldRegionStateChange(region);
|
||||
notifyListenersOnFoldRegionRemove(region);
|
||||
|
||||
myFoldRegionsProcessed = true;
|
||||
region.dispose();
|
||||
@@ -304,6 +305,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
|
||||
FoldRegion[] regions = getAllFoldRegions();
|
||||
for (FoldRegion region : regions) {
|
||||
if (!region.isExpanded()) notifyListenersOnFoldRegionStateChange(region);
|
||||
notifyListenersOnFoldRegionRemove(region);
|
||||
region.dispose();
|
||||
}
|
||||
doClearFoldRegions();
|
||||
@@ -591,6 +593,12 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyListenersOnFoldRegionRemove(@NotNull FoldRegion foldRegion) {
|
||||
for (FoldingListener listener : myListeners) {
|
||||
listener.beforeFoldRegionRemoved(foldRegion);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String dumpState() {
|
||||
|
||||
Reference in New Issue
Block a user