From 230af93ea19e9576869da95efcfc099884b74008 Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Fri, 4 Nov 2016 14:48:48 +0300 Subject: [PATCH] vcs: Refactoring - inlined "ValueConsumer" logic to "GenericDetailsLoader" --- .../openapi/vcs/GenericDetailsLoader.java | 13 +++--- .../intellij/openapi/vcs/ValueConsumer.java | 40 ------------------- 2 files changed, 8 insertions(+), 45 deletions(-) delete mode 100644 platform/vcs-api/src/com/intellij/openapi/vcs/ValueConsumer.java diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/GenericDetailsLoader.java b/platform/vcs-api/src/com/intellij/openapi/vcs/GenericDetailsLoader.java index 460358ef31f3..21d72cf7c115 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/GenericDetailsLoader.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/GenericDetailsLoader.java @@ -23,8 +23,9 @@ import org.jetbrains.annotations.Nullable; public class GenericDetailsLoader implements Details { private final Consumer myLoader; - private final ValueConsumer myValueConsumer; + private final PairConsumer myValueConsumer; private Id myCurrentlySelected; + private Id mySetId; /** * @param loader - is called in AWT. Should call {@link #take} with data when ready. Also in AWT @@ -32,15 +33,14 @@ public class GenericDetailsLoader implements Details { */ public GenericDetailsLoader(Consumer loader, PairConsumer valueConsumer) { myLoader = loader; - myValueConsumer = new ValueConsumer<>(valueConsumer); + myValueConsumer = valueConsumer; } @CalledInAwt public void updateSelection(@Nullable Id id, boolean force) { - myValueConsumer.setId(id); - Id previousId = myCurrentlySelected; myCurrentlySelected = id; + mySetId = null; if (force || !Comparing.equal(id, previousId)) { myLoader.consume(id); } @@ -49,7 +49,10 @@ public class GenericDetailsLoader implements Details { @CalledInAwt @Override public void take(Id id, Data data) { - myValueConsumer.consume(id, data); + if (!id.equals(mySetId) && id.equals(myCurrentlySelected)) { + mySetId = id; + myValueConsumer.consume(id, data); + } } @CalledInAwt diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/ValueConsumer.java b/platform/vcs-api/src/com/intellij/openapi/vcs/ValueConsumer.java deleted file mode 100644 index 9c53d5cc8633..000000000000 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/ValueConsumer.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2011 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.vcs; - -import com.intellij.util.PairConsumer; - -public class ValueConsumer { - private Id myId; - private Id mySetId; - private final PairConsumer myConsumer; - - protected ValueConsumer(PairConsumer consumer) { - myConsumer = consumer; - } - - public void consume(Id id, Data data) { - if (!id.equals(mySetId) && id.equals(myId)) { - mySetId = id; - myConsumer.consume(id, data); - } - } - - public void setId(Id id) { - myId = id; - mySetId = null; - } -} -- 2.23.3