1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.aequo.text.action;
14
15 import javax.swing.ListSelectionModel;
16
17 import org.abstracthorizon.aequo.action.BaseAction;
18 import org.abstracthorizon.aequo.text.TextModel;
19
20
21
22
23
24
25 public abstract class TextBaseAction extends BaseAction {
26
27
28 protected TextModel textModel;
29
30
31
32
33 public TextBaseAction() {
34 }
35
36
37
38
39
40 public void setTextModel(TextModel model) {
41 this.textModel = model;
42 }
43
44
45
46
47
48 public TextModel getTextModel() {
49 return textModel;
50 }
51
52
53
54
55
56
57 public boolean isOneSelected() {
58 ListSelectionModel selModel = getTextModel().getSelectionModel();
59 int min = selModel.getMinSelectionIndex();
60 int max = selModel.getMaxSelectionIndex();
61 return ((min >= 0) && (min == max));
62 }
63
64
65
66
67
68 public boolean isContinuousSelected() {
69 ListSelectionModel selModel = getTextModel().getSelectionModel();
70 int min = selModel.getMinSelectionIndex();
71 int max = selModel.getMaxSelectionIndex();
72 if ((min >= 0) && (min <= max)) {
73 boolean notInterrupted = true;
74 for (int i = min; (i < max) && notInterrupted; i++) {
75 notInterrupted = selModel.isSelectedIndex(i);
76 }
77 return notInterrupted;
78 } else {
79 return false;
80 }
81 }
82
83
84
85
86
87 public boolean isSelectionValid() {
88 ListSelectionModel selModel = getTextModel().getSelectionModel();
89 int min = selModel.getMinSelectionIndex();
90 int max = selModel.getMaxSelectionIndex();
91 return ((min >= 0) && (min <= max));
92 }
93
94 }