*/
public void invertColumnSelection(int first, int width, AlignmentI al)
{
- boolean hasHidden = al.getHiddenColumns().hasHidden();
+ boolean hasHidden = al.getHiddenColumns().hasHiddenColumns();
for (int i = first; i < width; i++)
{
if (contains(i))
selection = new IntList();
if (colsel.selection != null && colsel.selection.size() > 0)
{
- if (hiddenColumns.hasHidden())
+ if (hiddenColumns.hasHiddenColumns())
{
// only select visible columns in this columns selection
for (Integer col : colsel.getSelected())
{
try
{
-
- LOCK.readLock().lock();
+ LOCK.writeLock().lock();
if (copy != null)
{
if (copy.hiddenColumns != null)
}
} finally
{
- LOCK.readLock().unlock();
+ LOCK.writeLock().unlock();
}
}
{
LOCK.readLock().lock();
int size = 0;
- if (hasHidden())
+ if (hasHiddenColumns())
{
for (int[] range : hiddenColumns)
{
}
}
- /**
- * Answers if there are any hidden columns
- *
- * @return true if there are hidden columns
- */
- public boolean hasHidden()
- {
- try
- {
- LOCK.readLock().lock();
- return (hiddenColumns != null) && (!hiddenColumns.isEmpty());
- } finally
- {
- LOCK.readLock().unlock();
- }
-
- }
-
@Override
public boolean equals(Object obj)
{
*/
public void hideColumns(int start, int end)
{
- hideColumns(start, end, false);
- }
-
- /**
- * Adds the specified column range to the hidden columns
- *
- * @param start
- * @param end
- */
- private void hideColumns(int start, int end, boolean alreadyLocked)
- {
+ boolean wasAlreadyLocked = false;
try
{
-
- if (!alreadyLocked)
+ // check if the write lock was already locked by this thread,
+ // as this method can be called internally in loops within HiddenColumns
+ if (!LOCK.isWriteLockedByCurrentThread())
{
LOCK.writeLock().lock();
}
+ else
+ {
+ wasAlreadyLocked = true;
+ }
if (hiddenColumns == null)
{
hiddenColumns.add(new int[] { start, end });
} finally
{
- if (!alreadyLocked)
+ if (!wasAlreadyLocked)
{
LOCK.writeLock().unlock();
}
List<int[]> inserts = sr.getInsertions();
for (int[] r : inserts)
{
- hideColumns(r[0], r[1], true);
+ hideColumns(r[0], r[1]);
}
} finally
{
.nextSetBit(lastSet))
{
lastSet = inserts.nextClearBit(firstSet);
- hideColumns(firstSet, lastSet - 1, true);
+ hideColumns(firstSet, lastSet - 1);
}
} finally
{