Create a Name for the new custom piece of resized equipment. The name will be constructed by searching for the size of the equipment in its name. If found (and surrounded by '(', '/', or ')', it will be replaced. If not found, it will be added to the end surrounded by parenthesis. @param newSize
(SizeAdjustment newSize)
| 4764 | */ |
| 4765 | |
| 4766 | public String createNameForAutoResize(SizeAdjustment newSize) |
| 4767 | { |
| 4768 | // Make sure newSize is not null |
| 4769 | if (newSize == null) |
| 4770 | { |
| 4771 | return getName(); |
| 4772 | } |
| 4773 | |
| 4774 | String displayName = newSize.getDisplayName(); |
| 4775 | String thisName = getName(); |
| 4776 | String upName = thisName.toUpperCase(); |
| 4777 | |
| 4778 | String upThisSize = getSizeAdjustment().getDisplayName().toUpperCase(); |
| 4779 | |
| 4780 | int start = upName.indexOf(upThisSize); |
| 4781 | int end = start + upThisSize.length(); |
| 4782 | |
| 4783 | /* |
| 4784 | * if the name contains thisSize surrounded by /, ( or ) then replace |
| 4785 | * thisSize with newSize |
| 4786 | */ |
| 4787 | if (start > -1 && (upName.substring(start - 1).startsWith("(") || upName.substring(start - 1).startsWith("/")) |
| 4788 | && (upName.substring(end).startsWith(")") || upName.substring(end).startsWith("/"))) |
| 4789 | { |
| 4790 | return thisName.substring(0, start) + displayName + thisName.substring(end); |
| 4791 | } |
| 4792 | |
| 4793 | return thisName + " (" + displayName + ")"; |
| 4794 | } |
| 4795 | |
| 4796 | /** |
| 4797 | * Make this item virtual i.e. one that doesn't really exist and is only |