960 lblStatus.setText(getMsg(status.toString()));
961 }
962 Attribute info = psCurrent.getAttribute(PrinterInfo.class);
963 if (info != null) {
964 lblInfo.setText(info.toString());
965 }
966 btnProperties.setEnabled(uiFactory != null);
967 }
968 }
969
970 @SuppressWarnings("serial") // Superclass is not serializable across versions
971 private class PrintRangePanel extends JPanel
972 implements ActionListener, FocusListener
973 {
974 private final String strTitle = getMsg("border.printrange");
975 private final PageRanges prAll = new PageRanges(1, Integer.MAX_VALUE);
976 private JRadioButton rbAll, rbPages, rbSelect;
977 private JFormattedTextField tfRangeFrom, tfRangeTo;
978 private JLabel lblRangeTo;
979 private boolean prSupported;
980
981 public PrintRangePanel() {
982 super();
983
984 GridBagLayout gridbag = new GridBagLayout();
985 GridBagConstraints c = new GridBagConstraints();
986
987 setLayout(gridbag);
988 setBorder(BorderFactory.createTitledBorder(strTitle));
989
990 c.fill = GridBagConstraints.BOTH;
991 c.insets = compInsets;
992 c.gridwidth = GridBagConstraints.REMAINDER;
993
994 ButtonGroup bg = new ButtonGroup();
995 JPanel pnlTop = new JPanel(new FlowLayout(FlowLayout.LEADING));
996 rbAll = createRadioButton("radiobutton.rangeall", this);
997 rbAll.setSelected(true);
998 bg.add(rbAll);
999 pnlTop.add(rbAll);
1073 updateRangeAttribute();
1074 select = SunPageSelection.RANGE;
1075 }
1076
1077 if (isAWT) {
1078 asCurrent.add(select);
1079 }
1080 }
1081
1082 public void focusLost(FocusEvent e) {
1083 Object source = e.getSource();
1084
1085 if ((source == tfRangeFrom) || (source == tfRangeTo)) {
1086 updateRangeAttribute();
1087 }
1088 }
1089
1090 public void focusGained(FocusEvent e) {}
1091
1092 private void setupRangeWidgets() {
1093 boolean rangeEnabled = (rbPages.isSelected() && prSupported);
1094 tfRangeFrom.setEnabled(rangeEnabled);
1095 tfRangeTo.setEnabled(rangeEnabled);
1096 lblRangeTo.setEnabled(rangeEnabled);
1097 }
1098
1099 private void updateRangeAttribute() {
1100 String strFrom = tfRangeFrom.getText();
1101 String strTo = tfRangeTo.getText();
1102
1103 int min;
1104 int max;
1105
1106 try {
1107 min = Integer.parseInt(strFrom);
1108 } catch (NumberFormatException e) {
1109 min = 1;
1110 }
1111
1112 try {
1113 max = Integer.parseInt(strTo);
1119 min = 1;
1120 tfRangeFrom.setValue(1);
1121 }
1122
1123 if (max < min) {
1124 max = min;
1125 tfRangeTo.setValue(min);
1126 }
1127
1128 PageRanges pr = new PageRanges(min, max);
1129 asCurrent.add(pr);
1130 }
1131
1132 public void updateInfo() {
1133 Class<PageRanges> prCategory = PageRanges.class;
1134 prSupported = false;
1135
1136 if (psCurrent.isAttributeCategorySupported(prCategory) ||
1137 isAWT) {
1138 prSupported = true;
1139 }
1140
1141 SunPageSelection select = SunPageSelection.ALL;
1142 int min = 1;
1143 int max = 1;
1144
1145 PageRanges pr = (PageRanges)asCurrent.get(prCategory);
1146 if (pr != null) {
1147 if (!pr.equals(prAll)) {
1148 select = SunPageSelection.RANGE;
1149
1150 int[][] members = pr.getMembers();
1151 if ((members.length > 0) &&
1152 (members[0].length > 1)) {
1153 min = members[0][0];
1154 max = members[0][1];
1155 }
1156 }
1157 }
1158
1159 if (isAWT) {
1160 select = (SunPageSelection)asCurrent.get(
1161 SunPageSelection.class);
1162 }
1163
1164 if (select == SunPageSelection.ALL) {
1165 rbAll.setSelected(true);
1166 } else if (select == SunPageSelection.SELECTION) {
1167 // Comment this for now - rbSelect is not initialized
1168 // because Selection button is not added.
1169 // See PrintRangePanel above.
1170
1171 //rbSelect.setSelected(true);
1172 } else { // RANGE
1173 rbPages.setSelected(true);
1174 }
1175 tfRangeFrom.setValue(min);
1176 tfRangeTo.setValue(max);
1177 rbAll.setEnabled(prSupported);
1178 rbPages.setEnabled(prSupported);
1179 setupRangeWidgets();
1180 }
1181 }
1182
1183 @SuppressWarnings("serial") // Superclass is not serializable across versions
1184 private class CopiesPanel extends JPanel
1185 implements ActionListener, ChangeListener
1186 {
1187 private final String strTitle = getMsg("border.copies");
1188 private SpinnerNumberModel snModel;
1189 private JSpinner spinCopies;
1190 private JLabel lblCopies;
1191 private JCheckBox cbCollate;
1192 private boolean scSupported;
1193
1194 public CopiesPanel() {
1195 super();
1196
1197 GridBagLayout gridbag = new GridBagLayout();
1198 GridBagConstraints c = new GridBagConstraints();
|
960 lblStatus.setText(getMsg(status.toString()));
961 }
962 Attribute info = psCurrent.getAttribute(PrinterInfo.class);
963 if (info != null) {
964 lblInfo.setText(info.toString());
965 }
966 btnProperties.setEnabled(uiFactory != null);
967 }
968 }
969
970 @SuppressWarnings("serial") // Superclass is not serializable across versions
971 private class PrintRangePanel extends JPanel
972 implements ActionListener, FocusListener
973 {
974 private final String strTitle = getMsg("border.printrange");
975 private final PageRanges prAll = new PageRanges(1, Integer.MAX_VALUE);
976 private JRadioButton rbAll, rbPages, rbSelect;
977 private JFormattedTextField tfRangeFrom, tfRangeTo;
978 private JLabel lblRangeTo;
979 private boolean prSupported;
980 private boolean prPgRngSupported;
981
982 public PrintRangePanel() {
983 super();
984
985 GridBagLayout gridbag = new GridBagLayout();
986 GridBagConstraints c = new GridBagConstraints();
987
988 setLayout(gridbag);
989 setBorder(BorderFactory.createTitledBorder(strTitle));
990
991 c.fill = GridBagConstraints.BOTH;
992 c.insets = compInsets;
993 c.gridwidth = GridBagConstraints.REMAINDER;
994
995 ButtonGroup bg = new ButtonGroup();
996 JPanel pnlTop = new JPanel(new FlowLayout(FlowLayout.LEADING));
997 rbAll = createRadioButton("radiobutton.rangeall", this);
998 rbAll.setSelected(true);
999 bg.add(rbAll);
1000 pnlTop.add(rbAll);
1074 updateRangeAttribute();
1075 select = SunPageSelection.RANGE;
1076 }
1077
1078 if (isAWT) {
1079 asCurrent.add(select);
1080 }
1081 }
1082
1083 public void focusLost(FocusEvent e) {
1084 Object source = e.getSource();
1085
1086 if ((source == tfRangeFrom) || (source == tfRangeTo)) {
1087 updateRangeAttribute();
1088 }
1089 }
1090
1091 public void focusGained(FocusEvent e) {}
1092
1093 private void setupRangeWidgets() {
1094 boolean rangeEnabled = (rbPages.isSelected() && prPgRngSupported);
1095 tfRangeFrom.setEnabled(rangeEnabled);
1096 tfRangeTo.setEnabled(rangeEnabled);
1097 lblRangeTo.setEnabled(rangeEnabled);
1098 }
1099
1100 private void updateRangeAttribute() {
1101 String strFrom = tfRangeFrom.getText();
1102 String strTo = tfRangeTo.getText();
1103
1104 int min;
1105 int max;
1106
1107 try {
1108 min = Integer.parseInt(strFrom);
1109 } catch (NumberFormatException e) {
1110 min = 1;
1111 }
1112
1113 try {
1114 max = Integer.parseInt(strTo);
1120 min = 1;
1121 tfRangeFrom.setValue(1);
1122 }
1123
1124 if (max < min) {
1125 max = min;
1126 tfRangeTo.setValue(min);
1127 }
1128
1129 PageRanges pr = new PageRanges(min, max);
1130 asCurrent.add(pr);
1131 }
1132
1133 public void updateInfo() {
1134 Class<PageRanges> prCategory = PageRanges.class;
1135 prSupported = false;
1136
1137 if (psCurrent.isAttributeCategorySupported(prCategory) ||
1138 isAWT) {
1139 prSupported = true;
1140 prPgRngSupported = psCurrent.isAttributeValueSupported(prAll,
1141 docFlavor,
1142 asCurrent);
1143 }
1144
1145 SunPageSelection select = SunPageSelection.ALL;
1146 int min = 1;
1147 int max = 1;
1148
1149 PageRanges pr = (PageRanges)asCurrent.get(prCategory);
1150 if (pr != null) {
1151 if (!pr.equals(prAll)) {
1152 select = SunPageSelection.RANGE;
1153
1154 int[][] members = pr.getMembers();
1155 if ((members.length > 0) &&
1156 (members[0].length > 1)) {
1157 min = members[0][0];
1158 max = members[0][1];
1159 }
1160 }
1161 }
1162
1163 if (isAWT) {
1164 select = (SunPageSelection)asCurrent.get(
1165 SunPageSelection.class);
1166 }
1167
1168 if (select == SunPageSelection.ALL) {
1169 rbAll.setSelected(true);
1170 } else if (select == SunPageSelection.SELECTION) {
1171 // Comment this for now - rbSelect is not initialized
1172 // because Selection button is not added.
1173 // See PrintRangePanel above.
1174
1175 //rbSelect.setSelected(true);
1176 } else { // RANGE
1177 rbPages.setSelected(true);
1178 }
1179 tfRangeFrom.setValue(min);
1180 tfRangeTo.setValue(max);
1181 rbAll.setEnabled(prSupported);
1182 rbPages.setEnabled(prPgRngSupported);
1183 setupRangeWidgets();
1184 }
1185 }
1186
1187 @SuppressWarnings("serial") // Superclass is not serializable across versions
1188 private class CopiesPanel extends JPanel
1189 implements ActionListener, ChangeListener
1190 {
1191 private final String strTitle = getMsg("border.copies");
1192 private SpinnerNumberModel snModel;
1193 private JSpinner spinCopies;
1194 private JLabel lblCopies;
1195 private JCheckBox cbCollate;
1196 private boolean scSupported;
1197
1198 public CopiesPanel() {
1199 super();
1200
1201 GridBagLayout gridbag = new GridBagLayout();
1202 GridBagConstraints c = new GridBagConstraints();
|