2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-07-08 05:48:21 +02:00
|
|
|
package appeng.client.gui.implementations;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
|
2014-07-08 05:48:21 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.HashMap;
|
2014-10-01 16:02:24 +02:00
|
|
|
import java.util.HashSet;
|
2014-07-09 10:17:11 +02:00
|
|
|
import java.util.Iterator;
|
2014-10-01 16:02:24 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.WeakHashMap;
|
2014-07-08 05:48:21 +02:00
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import com.google.common.collect.HashMultimap;
|
|
|
|
|
2014-11-28 04:36:46 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-07-08 05:48:21 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-10-04 21:53:23 +02:00
|
|
|
import net.minecraft.nbt.NBTTagList;
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-10-04 21:53:23 +02:00
|
|
|
import appeng.api.AEApi;
|
2014-07-08 05:48:21 +02:00
|
|
|
import appeng.client.gui.AEBaseGui;
|
2014-07-09 10:17:11 +02:00
|
|
|
import appeng.client.gui.widgets.GuiScrollbar;
|
2014-09-30 15:50:11 +02:00
|
|
|
import appeng.client.gui.widgets.MEGuiTextField;
|
2014-07-09 10:17:11 +02:00
|
|
|
import appeng.client.me.ClientDCInternalInv;
|
|
|
|
import appeng.client.me.SlotDisconnected;
|
2014-07-08 05:48:21 +02:00
|
|
|
import appeng.container.implementations.ContainerInterfaceTerminal;
|
|
|
|
import appeng.core.localization.GuiText;
|
|
|
|
import appeng.parts.reporting.PartMonitor;
|
2014-10-01 16:02:24 +02:00
|
|
|
import appeng.util.Platform;
|
2014-07-08 05:48:21 +02:00
|
|
|
|
|
|
|
public class GuiInterfaceTerminal extends AEBaseGui
|
|
|
|
{
|
|
|
|
|
2014-09-30 15:50:11 +02:00
|
|
|
private static final int LINES_ON_PAGE = 6;
|
|
|
|
|
|
|
|
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
|
2014-11-04 12:34:56 +01:00
|
|
|
final int offsetX = 9;
|
2014-09-30 15:50:11 +02:00
|
|
|
|
2014-09-30 17:52:28 +02:00
|
|
|
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<Long, ClientDCInternalInv>();
|
|
|
|
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
|
|
|
private final ArrayList<String> names = new ArrayList<String>();
|
|
|
|
private final ArrayList<Object> lines = new ArrayList<Object>();
|
2014-07-08 05:48:21 +02:00
|
|
|
|
2014-10-01 16:02:24 +02:00
|
|
|
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<String, Set<Object>>();
|
|
|
|
|
2014-09-30 17:52:28 +02:00
|
|
|
private boolean refreshList = false;
|
2014-09-30 15:50:11 +02:00
|
|
|
private MEGuiTextField searchField;
|
2014-07-08 05:48:21 +02:00
|
|
|
|
2014-09-30 15:50:11 +02:00
|
|
|
public GuiInterfaceTerminal(InventoryPlayer inventoryPlayer, PartMonitor te)
|
|
|
|
{
|
2014-07-08 05:48:21 +02:00
|
|
|
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
|
2014-10-04 21:53:23 +02:00
|
|
|
this.myScrollBar = new GuiScrollbar();
|
|
|
|
this.xSize = 195;
|
|
|
|
this.ySize = 222;
|
2014-07-08 05:48:21 +02:00
|
|
|
}
|
|
|
|
|
2014-07-09 10:17:11 +02:00
|
|
|
@Override
|
|
|
|
public void initGui()
|
|
|
|
{
|
|
|
|
super.initGui();
|
2014-09-30 17:52:28 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myScrollBar.setLeft( 175 );
|
|
|
|
this.myScrollBar.setHeight( 106 );
|
|
|
|
this.myScrollBar.setTop( 18 );
|
|
|
|
|
|
|
|
this.searchField = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
|
|
|
|
this.searchField.setEnableBackgroundDrawing( false );
|
|
|
|
this.searchField.setMaxStringLength( 25 );
|
|
|
|
this.searchField.setTextColor( 0xFFFFFF );
|
|
|
|
this.searchField.setVisible( true );
|
|
|
|
this.searchField.setFocused( true );
|
2014-09-30 15:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void mouseClicked(int xCoord, int yCoord, int btn)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.searchField.mouseClicked( xCoord, yCoord, btn );
|
2014-09-30 15:50:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
|
2014-09-30 15:50:11 +02:00
|
|
|
{
|
2014-10-16 17:19:12 +02:00
|
|
|
this.searchField.setText( "" );
|
|
|
|
this.refreshList();
|
2014-09-30 15:50:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
super.mouseClicked( xCoord, yCoord, btn );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void keyTyped(char character, int key)
|
|
|
|
{
|
|
|
|
if ( !this.checkHotbarKeys( key ) )
|
|
|
|
{
|
|
|
|
if ( character == ' ' && this.searchField.getText().length() == 0 )
|
|
|
|
return;
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.searchField.textboxKeyTyped( character, key ) )
|
2014-09-30 15:50:11 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.refreshList();
|
2014-09-30 15:50:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
super.keyTyped( character, key );
|
|
|
|
}
|
|
|
|
}
|
2014-07-09 10:17:11 +02:00
|
|
|
}
|
|
|
|
|
2014-07-08 05:48:21 +02:00
|
|
|
@Override
|
|
|
|
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bindTexture( "guis/interfaceterminal.png" );
|
|
|
|
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
|
2014-07-09 10:17:11 +02:00
|
|
|
|
|
|
|
int offset = 17;
|
2014-12-29 15:13:47 +01:00
|
|
|
int ex = this.myScrollBar.getCurrentScroll();
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++)
|
2014-07-09 10:17:11 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Object lineObj = this.lines.get( ex + x );
|
2014-09-30 15:50:11 +02:00
|
|
|
if ( lineObj instanceof ClientDCInternalInv )
|
2014-07-09 10:17:11 +02:00
|
|
|
{
|
2014-09-30 15:50:11 +02:00
|
|
|
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-09-30 15:50:11 +02:00
|
|
|
GL11.glColor4f( 1, 1, 1, 1 );
|
2014-10-01 22:22:22 +02:00
|
|
|
int width = inv.inv.getSizeInventory() * 18;
|
|
|
|
this.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 139, width, 18 );
|
2014-07-09 10:17:11 +02:00
|
|
|
}
|
|
|
|
offset += 18;
|
|
|
|
}
|
2014-09-30 15:50:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.searchField != null )
|
|
|
|
this.searchField.drawTextBox();
|
2014-07-08 05:48:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
|
|
|
|
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
|
2014-07-08 05:48:21 +02:00
|
|
|
|
2014-07-09 10:17:11 +02:00
|
|
|
int offset = 17;
|
2014-12-29 15:13:47 +01:00
|
|
|
int ex = this.myScrollBar.getCurrentScroll();
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
Iterator<Object> o = this.inventorySlots.inventorySlots.iterator();
|
2014-07-09 10:17:11 +02:00
|
|
|
while (o.hasNext())
|
2014-07-08 05:48:21 +02:00
|
|
|
{
|
2014-07-09 10:17:11 +02:00
|
|
|
if ( o.next() instanceof SlotDisconnected )
|
|
|
|
o.remove();
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
for (int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++)
|
2014-07-09 10:17:11 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Object lineObj = this.lines.get( ex + x );
|
2014-09-30 15:50:11 +02:00
|
|
|
if ( lineObj instanceof ClientDCInternalInv )
|
2014-07-09 10:17:11 +02:00
|
|
|
{
|
2014-09-30 15:50:11 +02:00
|
|
|
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
|
|
|
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
|
2014-07-09 10:17:11 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
|
2014-07-09 10:17:11 +02:00
|
|
|
}
|
2014-09-30 15:50:11 +02:00
|
|
|
}
|
|
|
|
else if ( lineObj instanceof String )
|
|
|
|
{
|
|
|
|
String name = (String) lineObj;
|
2014-12-29 15:13:47 +01:00
|
|
|
int rows = this.byName.get( name ).size();
|
2014-09-30 15:50:11 +02:00
|
|
|
if ( rows > 1 )
|
2014-11-28 04:36:46 +01:00
|
|
|
name = name + " (" + rows + ')';
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
while (name.length() > 2 && this.fontRendererObj.getStringWidth( name ) > 155)
|
2014-09-30 15:50:11 +02:00
|
|
|
name = name.substring( 0, name.length() - 1 );
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
|
2014-07-09 10:17:11 +02:00
|
|
|
}
|
2014-09-30 15:50:11 +02:00
|
|
|
offset += 18;
|
2014-07-08 05:48:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void postUpdate(NBTTagCompound in)
|
|
|
|
{
|
|
|
|
if ( in.getBoolean( "clear" ) )
|
2014-07-09 10:17:11 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.byId.clear();
|
|
|
|
this.refreshList = true;
|
2014-07-09 10:17:11 +02:00
|
|
|
}
|
2014-07-08 05:48:21 +02:00
|
|
|
|
|
|
|
for (Object oKey : in.func_150296_c())
|
|
|
|
{
|
|
|
|
String key = (String) oKey;
|
|
|
|
if ( key.startsWith( "=" ) )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
|
|
|
|
NBTTagCompound invData = in.getCompoundTag( key );
|
2014-12-29 15:13:47 +01:00
|
|
|
ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
2014-07-08 05:48:21 +02:00
|
|
|
|
|
|
|
for (int x = 0; x < current.inv.getSizeInventory(); x++)
|
|
|
|
{
|
|
|
|
String which = Integer.toString( x );
|
|
|
|
if ( invData.hasKey( which ) )
|
|
|
|
current.inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( invData.getCompoundTag( which ) ) );
|
|
|
|
}
|
|
|
|
}
|
2014-10-01 15:20:42 +02:00
|
|
|
catch (NumberFormatException ignored)
|
2014-07-08 05:48:21 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( this.refreshList )
|
2014-07-08 05:48:21 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.refreshList = false;
|
2014-10-01 16:02:24 +02:00
|
|
|
// invalid caches on refresh
|
2014-12-29 15:13:47 +01:00
|
|
|
this.cachedSearches.clear();
|
|
|
|
this.refreshList();
|
2014-09-30 15:50:11 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-09-30 17:52:28 +02:00
|
|
|
/**
|
2014-10-01 16:02:24 +02:00
|
|
|
* Rebuilds the list of interfaces.
|
2014-09-30 17:52:28 +02:00
|
|
|
*
|
|
|
|
* Respects a search term if present (ignores case) and adding only matching patterns.
|
|
|
|
*/
|
2014-09-30 15:50:11 +02:00
|
|
|
private void refreshList()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.byName.clear();
|
2014-09-30 17:52:28 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
final String searchFilterLowerCase = this.searchField.getText().toLowerCase();
|
2014-07-08 05:48:21 +02:00
|
|
|
|
2014-10-01 16:02:24 +02:00
|
|
|
final Set<Object> cachedSearch = this.getCacheForSearchTerm( searchFilterLowerCase );
|
|
|
|
final boolean rebuild = cachedSearch.isEmpty();
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
for (ClientDCInternalInv entry : this.byId.values())
|
2014-09-30 15:50:11 +02:00
|
|
|
{
|
2014-10-01 16:02:24 +02:00
|
|
|
// ignore inventory if not doing a full rebuild or cache already marks it as miss.
|
|
|
|
if ( !rebuild && !cachedSearch.contains( entry ) )
|
2014-10-04 21:53:23 +02:00
|
|
|
{
|
2014-10-01 16:02:24 +02:00
|
|
|
continue;
|
2014-10-04 21:53:23 +02:00
|
|
|
}
|
2014-10-01 16:02:24 +02:00
|
|
|
|
2014-09-30 17:52:28 +02:00
|
|
|
// Shortcut to skip any filter if search term is ""/empty
|
|
|
|
boolean found = searchFilterLowerCase.isEmpty();
|
|
|
|
|
|
|
|
// Search if the current inventory holds a pattern containing the search term.
|
2014-11-28 04:36:46 +01:00
|
|
|
if ( !found && !searchFilterLowerCase.isEmpty() )
|
2014-09-30 17:52:28 +02:00
|
|
|
{
|
|
|
|
for (ItemStack itemStack : entry.inv)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
found = this.itemStackMatchesSearchTerm( itemStack, searchFilterLowerCase );
|
2014-10-04 21:53:23 +02:00
|
|
|
if ( found )
|
2014-09-30 17:52:28 +02:00
|
|
|
{
|
2014-10-04 21:53:23 +02:00
|
|
|
break;
|
2014-09-30 17:52:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if found, filter skipped or machine name matching the search term, add it
|
|
|
|
if ( found || entry.getName().toLowerCase().contains( searchFilterLowerCase ) )
|
2014-10-01 16:02:24 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.byName.put( entry.getName(), entry );
|
2014-10-01 16:02:24 +02:00
|
|
|
cachedSearch.add( entry );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cachedSearch.remove( entry );
|
|
|
|
}
|
2014-09-30 15:50:11 +02:00
|
|
|
}
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.names.clear();
|
|
|
|
this.names.addAll( this.byName.keySet() );
|
2014-07-13 03:20:21 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
Collections.sort( this.names );
|
2014-07-13 03:20:21 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lines.clear();
|
|
|
|
this.lines.ensureCapacity( this.getMaxRows() );
|
2014-09-30 17:52:28 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
for (String n : this.names)
|
2014-09-30 15:50:11 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lines.add( n );
|
2014-07-13 03:20:21 +02:00
|
|
|
|
2014-09-30 15:50:11 +02:00
|
|
|
ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<ClientDCInternalInv>();
|
2014-12-29 15:13:47 +01:00
|
|
|
clientInventories.addAll( this.byName.get( n ) );
|
2014-07-09 10:17:11 +02:00
|
|
|
|
2014-09-30 15:50:11 +02:00
|
|
|
Collections.sort( clientInventories );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lines.addAll( clientInventories );
|
2014-07-08 05:48:21 +02:00
|
|
|
}
|
2014-09-30 15:50:11 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myScrollBar.setRange( 0, this.lines.size() - LINES_ON_PAGE, 2 );
|
2014-07-08 05:48:21 +02:00
|
|
|
}
|
|
|
|
|
2014-10-04 21:53:23 +02:00
|
|
|
private boolean itemStackMatchesSearchTerm(ItemStack itemStack, String searchTerm)
|
|
|
|
{
|
|
|
|
if ( itemStack == null )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NBTTagCompound encodedValue = itemStack.getTagCompound();
|
|
|
|
|
|
|
|
if ( encodedValue == null )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Potential later use to filter by input
|
|
|
|
// NBTTagList inTag = encodedValue.getTagList( "in", 10 );
|
|
|
|
NBTTagList outTag = encodedValue.getTagList( "out", 10 );
|
|
|
|
|
|
|
|
for (int i = 0; i < outTag.tagCount(); i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT( outTag.getCompoundTagAt( i ) );
|
|
|
|
if ( parsedItemStack != null )
|
|
|
|
{
|
|
|
|
String displayName = Platform.getItemDisplayName( AEApi.instance().storage().createItemStack( parsedItemStack ) ).toLowerCase();
|
|
|
|
if ( displayName.contains( searchTerm ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-10-01 16:02:24 +02:00
|
|
|
/**
|
|
|
|
* Tries to retrieve a cache for a with search term as keyword.
|
|
|
|
*
|
|
|
|
* If this cache should be empty, it will populate it with an earlier cache if available or at least the cache for
|
|
|
|
* the empty string.
|
2015-02-03 12:04:13 +01:00
|
|
|
*
|
2014-10-01 16:02:24 +02:00
|
|
|
* @param searchTerm
|
|
|
|
* the corresponding search
|
|
|
|
* @return a Set matching a superset of the search term
|
|
|
|
*/
|
|
|
|
private Set<Object> getCacheForSearchTerm(String searchTerm)
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( !this.cachedSearches.containsKey( searchTerm ) )
|
2014-10-01 16:02:24 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.cachedSearches.put( searchTerm, new HashSet<Object>() );
|
2014-10-01 16:02:24 +02:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
Set<Object> cache = this.cachedSearches.get( searchTerm );
|
2014-10-01 16:02:24 +02:00
|
|
|
|
2014-10-04 21:53:23 +02:00
|
|
|
if ( cache.isEmpty() && searchTerm.length() > 1 )
|
2014-10-01 16:02:24 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
cache.addAll( this.getCacheForSearchTerm( searchTerm.substring( 0, searchTerm.length() - 1 ) ) );
|
2014-10-04 21:53:23 +02:00
|
|
|
return cache;
|
2014-10-01 16:02:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return cache;
|
|
|
|
}
|
|
|
|
|
2014-09-30 17:52:28 +02:00
|
|
|
/**
|
|
|
|
* The max amount of unique names and each inv row. Not affected by the filtering.
|
|
|
|
*
|
2014-10-01 10:53:08 +02:00
|
|
|
* @return max amount of unique names and each inv row
|
2014-09-30 17:52:28 +02:00
|
|
|
*/
|
|
|
|
private int getMaxRows()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.names.size() + this.byId.size();
|
2014-09-30 17:52:28 +02:00
|
|
|
}
|
|
|
|
|
2014-07-13 03:20:21 +02:00
|
|
|
private ClientDCInternalInv getById(long id, long sortBy, String string)
|
2014-07-08 05:48:21 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
ClientDCInternalInv o = this.byId.get( id );
|
2014-07-08 05:48:21 +02:00
|
|
|
|
|
|
|
if ( o == null )
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
|
|
|
|
this.refreshList = true;
|
2014-07-08 05:48:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
}
|