Update active tag tab containing edited tag

Closes #6061

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-10-18 14:22:58 +02:00
parent 7cc40e2215
commit 6c514033f7
2 changed files with 28 additions and 6 deletions

View File

@@ -32,6 +32,7 @@ import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.awt.event.MouseWheelEvent;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.inject.Inject;
import net.runelite.api.Client;
@@ -256,6 +257,13 @@ public class BankTagsPlugin extends Plugin implements MouseWheelListener
}
tagManager.setTagString(itemId, newTags);
// Check both previous and current tags in case the tag got removed in new tags or in case
// the tag got added in new tags
final List<String> initialTags = SPLITTER.splitToList(initialValue.toLowerCase());
final List<String> tags = SPLITTER.splitToList(newTags.toLowerCase());
tabInterface.updateTabIfActive(initialTags);
tabInterface.updateTabIfActive(tags);
});
}
else

View File

@@ -38,6 +38,7 @@ import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
@@ -438,14 +439,17 @@ public class TabInterface
.map(Item::getId)
.collect(Collectors.toList());
if (activeTab != null && event.getMenuTarget() != null && Text.removeTags(event.getMenuTarget()).equals(activeTab.getTag()))
if (!Strings.isNullOrEmpty(event.getMenuTarget()))
{
for (Integer item : items)
if (activeTab != null && Text.removeTags(event.getMenuTarget()).equals(activeTab.getTag()))
{
tagManager.addTag(item, activeTab.getTag());
}
for (Integer item : items)
{
tagManager.addTag(item, activeTab.getTag());
}
openTag(TAG_SEARCH + activeTab.getTag());
openTag(TAG_SEARCH + activeTab.getTag());
}
}
else
{
@@ -456,12 +460,14 @@ public class TabInterface
return;
}
final List<String> tags = SPLITTER.splitToList(newTags);
final List<String> tags = SPLITTER.splitToList(newTags.toLowerCase());
for (Integer item : items)
{
tagManager.addTags(item, tags);
}
updateTabIfActive(tags);
});
}
}
@@ -598,6 +604,14 @@ public class TabInterface
}
}
public void updateTabIfActive(final Collection<String> tags)
{
if (activeTab != null && tags.contains(activeTab.getTag()))
{
openTag(TAG_SEARCH + activeTab.getTag());
}
}
public void handleDrag(boolean isDragging)
{
if (isHidden())