{
x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x);
}
-
- if (x >= av.getAlignment().getWidth())
- {
- res = av.getAlignment().getWidth() - 1;
- }
- else
- {
- res = x;
- }
+ res = Math.min(x, av.getAlignment().getWidth() - 1);
min = res;
max = res;
*/
protected void rightMouseButtonPressed(MouseEvent evt, final int res)
{
+ JPopupMenu pop = buildPopupMenu(res);
+ if (pop.getSubElements().length > 0)
+ {
+ pop.show(this, evt.getX(), evt.getY());
+ }
+ }
+
+ /**
+ * Builds a popup menu with 'Hide' or 'Reveal' options, or both, or neither
+ *
+ * @param res
+ * column number (0..)
+ * @return
+ */
+ protected JPopupMenu buildPopupMenu(final int res)
+ {
JPopupMenu pop = new JPopupMenu();
/*
- * grab the hidden range in case mouseMoved nulls it
+ * logic here depends on 'reveal', set in mouseMoved;
+ * grab the hidden range in case mouseMoved nulls it later
*/
final int[] hiddenRange = reveal;
if (hiddenRange != null)
});
pop.add(item);
}
- pop.show(this, evt.getX(), evt.getY());
}
- else if (av.getColumnSelection().contains(res))
+
+ if (av.getColumnSelection().contains(res))
{
JMenuItem item = new JMenuItem(
MessageManager.getString("label.hide_columns"));
}
});
pop.add(item);
- pop.show(this, evt.getX(), evt.getY());
}
+ return pop;
}
/**