Lines 210-220
Link Here
|
210 |
* @since 1.34 |
210 |
* @since 1.34 |
211 |
*/ |
211 |
*/ |
212 |
public static final int BUSY = 2*32768; |
212 |
public static final int BUSY = 2*32768; |
|
|
213 |
|
213 |
/** |
214 |
/** |
|
|
215 |
* Indicates that the tab should be highlighted to draw user's attention. |
216 |
* @since 1.38 |
217 |
*/ |
218 |
public static final int HIGHLIGHT = 2*BUSY; |
219 |
/** |
214 |
* Indicates the last constant defined - renderers that wish to add their |
220 |
* Indicates the last constant defined - renderers that wish to add their |
215 |
* own bitmasks should use multiples of this number |
221 |
* own bitmasks should use multiples of this number |
216 |
*/ |
222 |
*/ |
217 |
public static int STATE_LAST = BUSY; |
223 |
public static int STATE_LAST = HIGHLIGHT; |
218 |
|
224 |
|
219 |
|
225 |
|
220 |
private int pressedIndex = -1; |
226 |
private int pressedIndex = -1; |
Lines 297-302
Link Here
|
297 |
if (isAlarmTab(tab)) { |
303 |
if (isAlarmTab(tab)) { |
298 |
result |= ATTENTION; |
304 |
result |= ATTENTION; |
299 |
} |
305 |
} |
|
|
306 |
if (isHighlightTab( tab)) { |
307 |
result |= HIGHLIGHT; |
308 |
} |
300 |
return result; |
309 |
return result; |
301 |
} |
310 |
} |
302 |
|
311 |
|
Lines 402-407
Link Here
|
402 |
selectedIndex = i; |
411 |
selectedIndex = i; |
403 |
curr = i; |
412 |
curr = i; |
404 |
removeAlarmTab(i); |
413 |
removeAlarmTab(i); |
|
|
414 |
removeHighlightTab(i); |
405 |
possibleChange(prev, curr, SELECTED); |
415 |
possibleChange(prev, curr, SELECTED); |
406 |
return prev; |
416 |
return prev; |
407 |
} |
417 |
} |
Lines 431-436
Link Here
|
431 |
active = b; |
441 |
active = b; |
432 |
possibleChange(prev, b, ACTIVE); |
442 |
possibleChange(prev, b, ACTIVE); |
433 |
removeAlarmTab(selectedIndex); |
443 |
removeAlarmTab(selectedIndex); |
|
|
444 |
removeHighlightTab(selectedIndex); |
434 |
return prev; |
445 |
return prev; |
435 |
} |
446 |
} |
436 |
|
447 |
|
Lines 457-462
Link Here
|
457 |
} |
468 |
} |
458 |
} |
469 |
} |
459 |
|
470 |
|
|
|
471 |
private final HashSet<Integer> highlightTabs = new HashSet<Integer>(6); |
472 |
|
473 |
private boolean isHighlightTab(int tab) { |
474 |
return highlightTabs.contains( tab ) && !alarmTabs.contains( tab ); |
475 |
} |
476 |
|
477 |
/** |
478 |
* Highlight the given tab. |
479 |
* @param highlightTab |
480 |
* @since 1.38 |
481 |
*/ |
482 |
public final void addHighlightTab(int highlightTab) { |
483 |
boolean added = highlightTabs.add(highlightTab); |
484 |
if (added) { |
485 |
repaintTab (highlightTab); |
486 |
} |
487 |
} |
488 |
|
460 |
/** Remove a tab to the list of those which should "flash" or otherwise give |
489 |
/** Remove a tab to the list of those which should "flash" or otherwise give |
461 |
* some notification to the user to get their attention */ |
490 |
* some notification to the user to get their attention */ |
462 |
public final void removeAlarmTab (int alarmTab) { |
491 |
public final void removeAlarmTab (int alarmTab) { |
Lines 475-480
Link Here
|
475 |
} |
504 |
} |
476 |
} |
505 |
} |
477 |
|
506 |
|
|
|
507 |
/** |
508 |
* Turn tab highlight off. |
509 |
* @param highlightTab |
510 |
* @since 1.38 |
511 |
*/ |
512 |
public final void removeHighlightTab(int highlightTab) { |
513 |
boolean removed = highlightTabs.remove( highlightTab ); |
514 |
if( removed ) { |
515 |
repaintTab( highlightTab ); |
516 |
} |
517 |
} |
518 |
|
478 |
private Timer alarmTimer = null; |
519 |
private Timer alarmTimer = null; |
479 |
private boolean attentionToggle = false; |
520 |
private boolean attentionToggle = false; |
480 |
private void startAlarmTimer() { |
521 |
private void startAlarmTimer() { |
Lines 519-529
Link Here
|
519 |
} |
560 |
} |
520 |
|
561 |
|
521 |
boolean hasAlarmTabs() { |
562 |
boolean hasAlarmTabs() { |
522 |
return alarmTabs != null && !alarmTabs.isEmpty(); |
563 |
return !alarmTabs.isEmpty(); |
523 |
} |
564 |
} |
524 |
|
565 |
|
525 |
void pruneAlarmTabs(int max) { |
566 |
boolean hasHighlightTabs() { |
526 |
if (!hasAlarmTabs()) { |
567 |
return !highlightTabs.isEmpty(); |
|
|
568 |
} |
569 |
|
570 |
void pruneTabs(int max) { |
571 |
if (!(hasAlarmTabs() || hasHighlightTabs())) { |
527 |
return; |
572 |
return; |
528 |
} |
573 |
} |
529 |
for (Iterator i=alarmTabs.iterator(); i.hasNext();) { |
574 |
for (Iterator i=alarmTabs.iterator(); i.hasNext();) { |
Lines 531-536
Link Here
|
531 |
i.remove(); |
576 |
i.remove(); |
532 |
} |
577 |
} |
533 |
} |
578 |
} |
|
|
579 |
for (Iterator i=highlightTabs.iterator(); i.hasNext();) { |
580 |
if (((Integer) i.next()).intValue() >= max) { |
581 |
i.remove(); |
582 |
} |
583 |
} |
534 |
if (alarmTabs.isEmpty()) { |
584 |
if (alarmTabs.isEmpty()) { |
535 |
stopAlarmTimer(); |
585 |
stopAlarmTimer(); |
536 |
} |
586 |
} |
Lines 545-553
Link Here
|
545 |
//Handling of insertions/deletions where we'll need to update the |
595 |
//Handling of insertions/deletions where we'll need to update the |
546 |
//list of blinking tabs here. |
596 |
//list of blinking tabs here. |
547 |
void intervalAdded (ListDataEvent evt) { |
597 |
void intervalAdded (ListDataEvent evt) { |
548 |
if (!hasAlarmTabs()) return; |
|
|
549 |
int start = evt.getIndex0(); |
598 |
int start = evt.getIndex0(); |
550 |
int end = evt.getIndex1(); |
599 |
int end = evt.getIndex1(); |
|
|
600 |
if (hasAlarmTabs()) { |
551 |
int[] alarms = (int[]) Utilities.toPrimitiveArray((Integer[]) alarmTabs.toArray(new Integer[0])); |
601 |
int[] alarms = (int[]) Utilities.toPrimitiveArray((Integer[]) alarmTabs.toArray(new Integer[0])); |
552 |
boolean changed = false; |
602 |
boolean changed = false; |
553 |
for (int i=0; i < alarms.length; i++) { |
603 |
for (int i=0; i < alarms.length; i++) { |
Lines 563-571
Link Here
|
563 |
} |
613 |
} |
564 |
} |
614 |
} |
565 |
} |
615 |
} |
|
|
616 |
if( hasHighlightTabs() ) { |
617 |
int[] highlights = (int[]) Utilities.toPrimitiveArray((Integer[]) highlightTabs.toArray(new Integer[0])); |
618 |
boolean changed = false; |
619 |
for (int i=0; i < highlights.length; i++) { |
620 |
if (highlights[i] >= start) { |
621 |
highlights[i] += (end - start) + 1; |
622 |
changed = true; |
623 |
} |
624 |
} |
625 |
if (changed) { |
626 |
highlightTabs.clear(); |
627 |
for (int i=0; i < highlights.length; i++) { |
628 |
addHighlightTab(highlights[i]); |
629 |
} |
630 |
} |
631 |
} |
632 |
} |
566 |
|
633 |
|
567 |
void intervalRemoved (ListDataEvent evt) { |
634 |
void intervalRemoved (ListDataEvent evt) { |
568 |
if (!hasAlarmTabs()) return; |
635 |
if (hasAlarmTabs()) { |
569 |
int start = evt.getIndex0(); |
636 |
int start = evt.getIndex0(); |
570 |
int end = evt.getIndex1(); |
637 |
int end = evt.getIndex1(); |
571 |
|
638 |
|
Lines 625-633
Link Here
|
625 |
} |
692 |
} |
626 |
} |
693 |
} |
627 |
} |
694 |
} |
|
|
695 |
if( hasAlarmTabs() ) { |
696 |
int start = evt.getIndex0(); |
697 |
int end = evt.getIndex1(); |
628 |
|
698 |
|
|
|
699 |
int[] highlights = (int[]) Utilities.toPrimitiveArray((Integer[]) highlightTabs.toArray(new Integer[0])); |
700 |
Arrays.sort(highlights); |
701 |
|
702 |
boolean changed = false; |
703 |
for (int i=0; i < highlights.length; i++) { |
704 |
if (highlights[i] >= start && highlights[i] <= end) { |
705 |
highlights[i] = -1; |
706 |
changed = true; |
707 |
} |
708 |
} |
709 |
for (int i=0; i < highlights.length; i++) { |
710 |
if (highlights[i] > end) { |
711 |
highlights[i] -= (end - start) + 1; |
712 |
changed = true; |
713 |
} |
714 |
} |
715 |
if (changed) { |
716 |
highlightTabs.clear(); |
717 |
for (int i=0; i < highlights.length; i++) { |
718 |
if (highlights[i] != -1) { |
719 |
addHighlightTab(highlights[i]); |
720 |
} |
721 |
} |
722 |
} |
723 |
} |
724 |
} |
725 |
|
629 |
void indicesAdded (ComplexListDataEvent e) { |
726 |
void indicesAdded (ComplexListDataEvent e) { |
630 |
if (!hasAlarmTabs()) return; |
727 |
if (hasAlarmTabs()) { |
631 |
int[] alarms = (int[]) Utilities.toPrimitiveArray((Integer[]) alarmTabs.toArray(new Integer[0])); |
728 |
int[] alarms = (int[]) Utilities.toPrimitiveArray((Integer[]) alarmTabs.toArray(new Integer[0])); |
632 |
java.util.Arrays.sort(alarms); |
729 |
java.util.Arrays.sort(alarms); |
633 |
|
730 |
|
Lines 652-671
Link Here
|
652 |
} |
749 |
} |
653 |
} |
750 |
} |
654 |
} |
751 |
} |
|
|
752 |
if( hasHighlightTabs() ) { |
753 |
int[] highlights = (int[]) Utilities.toPrimitiveArray((Integer[]) highlightTabs.toArray(new Integer[0])); |
754 |
java.util.Arrays.sort(highlights); |
655 |
|
755 |
|
|
|
756 |
int[] indices = e.getIndices(); |
757 |
java.util.Arrays.sort(indices); |
758 |
|
759 |
boolean changed = false; |
760 |
for (int i=0; i < indices.length; i++) { |
761 |
for (int j=0; j < highlights.length; j++) { |
762 |
if (highlights[j] >= indices[i]) { |
763 |
highlights[j]++; |
764 |
changed = true; |
765 |
} |
766 |
} |
767 |
} |
768 |
if (changed) { |
769 |
highlightTabs.clear(); |
770 |
for (int i=0; i < highlights.length; i++) { |
771 |
if (highlights[i] != -1) { |
772 |
addHighlightTab(highlights[i]); |
773 |
} |
774 |
} |
775 |
} |
776 |
} |
777 |
} |
778 |
|
656 |
void indicesRemoved (ComplexListDataEvent e) { |
779 |
void indicesRemoved (ComplexListDataEvent e) { |
657 |
if (!hasAlarmTabs()) return; |
780 |
if (hasAlarmTabs()) { |
658 |
int[] indices = e.getIndices(); |
781 |
int[] indices = e.getIndices(); |
659 |
java.util.Arrays.sort(indices); |
782 |
java.util.Arrays.sort(indices); |
660 |
|
783 |
|
661 |
int[] alarms = (int[]) Utilities.toPrimitiveArray((Integer[]) alarmTabs.toArray(new Integer[0])); |
784 |
int[] alarms = (int[]) Utilities.toPrimitiveArray((Integer[]) alarmTabs.toArray(new Integer[0])); |
662 |
java.util.Arrays.sort(alarms); |
785 |
java.util.Arrays.sort(alarms); |
663 |
|
786 |
|
664 |
if (alarms[alarms.length -1] < indices[0]) { |
787 |
if (alarms[alarms.length -1] >= indices[0]) { |
665 |
//Some tab removed after the last blinking tab, don't care |
|
|
666 |
return; |
667 |
} |
668 |
|
669 |
boolean changed = false; |
788 |
boolean changed = false; |
670 |
for (int i=0; i < alarms.length; i++) { |
789 |
for (int i=0; i < alarms.length; i++) { |
671 |
//First weed out all deleted alarm tabs |
790 |
//First weed out all deleted alarm tabs |
Lines 700-711
Link Here
|
700 |
stopAlarmTimer(); |
819 |
stopAlarmTimer(); |
701 |
} |
820 |
} |
702 |
} |
821 |
} |
|
|
822 |
} else { |
823 |
//Some tab removed after the last blinking tab, don't care |
824 |
} |
703 |
|
825 |
|
|
|
826 |
} |
827 |
if( hasHighlightTabs() ) { |
828 |
int[] indices = e.getIndices(); |
829 |
java.util.Arrays.sort(indices); |
830 |
|
831 |
int[] highlights = (int[]) Utilities.toPrimitiveArray((Integer[]) highlightTabs.toArray(new Integer[0])); |
832 |
java.util.Arrays.sort(highlights); |
833 |
|
834 |
if (highlights[highlights.length -1] >= indices[0]) { |
835 |
|
836 |
boolean changed = false; |
837 |
for (int i=0; i < highlights.length; i++) { |
838 |
//First weed out all deleted alarm tabs |
839 |
for (int j=0; j < indices.length; j++) { |
840 |
if (highlights[i] == indices[j]) { |
841 |
highlights[i] = -1; |
842 |
changed = true; |
843 |
} |
844 |
} |
845 |
} |
846 |
for (int i=0; i < highlights.length; i++) { |
847 |
//Now decrement those that remain that are affected |
848 |
int alarm = highlights[i]; |
849 |
for (int j=0; j < indices.length; j++) { |
850 |
if (alarm > indices[j]) { |
851 |
highlights[i]--; |
852 |
changed = true; |
853 |
} |
854 |
} |
855 |
} |
856 |
|
857 |
if (changed) { |
858 |
highlightTabs.clear(); |
859 |
for (int i=0; i < highlights.length; i++) { |
860 |
if (highlights[i] >= 0) { |
861 |
addHighlightTab(highlights[i]); |
862 |
} |
863 |
} |
864 |
} |
865 |
} |
866 |
} |
704 |
repaintAllTabs(); |
867 |
repaintAllTabs(); |
705 |
} |
868 |
} |
706 |
|
869 |
|
707 |
void indicesChanged (ComplexListDataEvent e) { |
870 |
void indicesChanged (ComplexListDataEvent e) { |
708 |
if (!hasAlarmTabs()) return; |
871 |
if (hasAlarmTabs()) { |
709 |
if (e instanceof VeryComplexListDataEvent) { //it always will be |
872 |
if (e instanceof VeryComplexListDataEvent) { //it always will be |
710 |
VeryComplexListDataEvent ve = (VeryComplexListDataEvent) e; |
873 |
VeryComplexListDataEvent ve = (VeryComplexListDataEvent) e; |
711 |
|
874 |
|
Lines 738-745
Link Here
|
738 |
} |
901 |
} |
739 |
} |
902 |
} |
740 |
} |
903 |
} |
|
|
904 |
if( hasHighlightTabs() ) { |
905 |
if (e instanceof VeryComplexListDataEvent) { //it always will be |
906 |
VeryComplexListDataEvent ve = (VeryComplexListDataEvent) e; |
741 |
|
907 |
|
|
|
908 |
ArrayDiff dif = ((VeryComplexListDataEvent) e).getDiff(); |
742 |
|
909 |
|
|
|
910 |
List old = Arrays.asList(dif.getOldData()); |
911 |
List nue = Arrays.asList(dif.getNewData()); |
912 |
|
913 |
int[] highlights = (int[]) Utilities.toPrimitiveArray((Integer[]) highlightTabs.toArray(new Integer[0])); |
914 |
|
915 |
boolean changed = false; |
916 |
for (int i=0; i < highlights.length; i++) { |
917 |
Object o = old.get(highlights[i]); |
918 |
int idx = nue.indexOf(o); |
919 |
changed |= idx != highlights[i]; |
920 |
highlights[i] = nue.indexOf(o); |
921 |
} |
922 |
if (changed) { |
923 |
highlightTabs.clear(); |
924 |
for (int i=0; i < highlights.length; i++) { |
925 |
if (highlights[i] >= 0) { |
926 |
addHighlightTab(highlights[i]); |
927 |
} |
928 |
} |
929 |
} |
930 |
} |
931 |
} |
932 |
} |
933 |
|
934 |
|
743 |
void contentsChanged(ListDataEvent evt) { |
935 |
void contentsChanged(ListDataEvent evt) { |
744 |
if (!hasAlarmTabs()) return; |
936 |
if (!hasAlarmTabs()) return; |
745 |
//Do nothing, just means some text or icons changed |
937 |
//Do nothing, just means some text or icons changed |
Lines 896-901
Link Here
|
896 |
} |
1088 |
} |
897 |
break; |
1089 |
break; |
898 |
case ATTENTION: |
1090 |
case ATTENTION: |
|
|
1091 |
case HIGHLIGHT: |
899 |
go = true; |
1092 |
go = true; |
900 |
} |
1093 |
} |
901 |
if (go) { |
1094 |
if (go) { |