SetOfIntegerSyntax pageRange = null;
if(printRangeAll.isSelected()){
pageRange = new PageRanges(1, pageCount);
if(printRangeSubset.getSelectedIndex() == 0)
return pageRange;
if(printRangeSubset.getSelectedIndex() == 1){
String members = "";
int i = -1;
while ((i = pageRange.next(i)) != -1) {
if(i % 2 == 1){
members += i+",";
}
}
StringBuilder sb = new StringBuilder(members);
sb.deleteCharAt(members.length() - 1);
members = sb.toString();
pageRange = new PageRanges(members);
}else if(printRangeSubset.getSelectedIndex() == 2){
String members = "";
int i = -1;
while ((i = pageRange.next(i)) != -1) {
if(i % 2 == 0){
members += i+",";
}
}
StringBuilder sb = new StringBuilder(members);
sb.deleteCharAt(members.length() - 1);
members = sb.toString();
pageRange = new PageRanges(members);
}
}else if(printRangeCurrentPage.isSelected()){
pageRange = new PageRanges(currentPage);
}else if(printRangeCurrentView.isSelected()){
pageRange = new PageRanges(currentPage);
}else if(printRangeFrom.isSelected()){
int start, end;
try {
start = Integer.parseInt(pagesFrom.getText());
} catch (NumberFormatException e) {
pagesFrom.setText(""+1);
start = 1;
}
try {
end = Integer.parseInt(pagesTo.getText());
} catch(NumberFormatException e) {
pagesTo.setText(String.valueOf(pageCount));
end = pageCount;
}
//Check values in range
if (start < 0) {
start = 1;
pagesFrom.setText(""+1);
} else if (start > pageCount) {
start = pageCount;
pagesFrom.setText(String.valueOf(pageCount));
}
if (end < 0) {
end = 1;
pagesTo.setText(""+1);
} else if (end > pageCount) {
end = pageCount;
pagesTo.setText(String.valueOf(pageCount));
}
if(start>end){
int tmp=end;
end=start;
start=tmp;
if(SimpleViewer.showMessages)
JOptionPane.showMessageDialog(this,Messages.getMessage("PdfViewerPrint.SwapValues"));
}
pageRange = new PageRanges(start,end);
if(printRangeSubset.getSelectedIndex() == 0)
return pageRange;
if(printRangeSubset.getSelectedIndex() == 1){
String members = "";
int i = -1;
while ((i = pageRange.next(i)) != -1) {
if(i % 2 == 1){
members += i+",";
}
}
StringBuilder sb = new StringBuilder(members);
if (members.length()==0)
return null;
sb.deleteCharAt(members.length() - 1);
members = sb.toString();
pageRange = new PageRanges(members);
}else if(printRangeSubset.getSelectedIndex() == 2){
String members = "";
int i = -1;
while ((i = pageRange.next(i)) != -1) {
if(i % 2 == 0){
members += i+",";
}
}
StringBuilder sb = new StringBuilder(members);
int length=members.length();
if(length>0)
sb.deleteCharAt(length - 1);
members = sb.toString();
if(members.length()>0)
pageRange = new PageRanges(members);
else
pageRange=null;
}
}