< prev index next >

src/java.desktop/share/classes/javax/print/ServiceUI.java

Print this page




 176                     break;
 177                 }
 178             }
 179 
 180             if (defaultIndex < 0) {
 181                 throw new IllegalArgumentException("services must contain " +
 182                                                    "defaultService");
 183             }
 184         } else {
 185             defaultIndex = 0;
 186         }
 187 
 188         // For now we set owner to null. In the future, it may be passed
 189         // as an argument.
 190         Window owner = null;
 191 
 192         Rectangle gcBounds = (gc == null) ?  GraphicsEnvironment.
 193             getLocalGraphicsEnvironment().getDefaultScreenDevice().
 194             getDefaultConfiguration().getBounds() : gc.getBounds();
 195 


 196         ServiceDialog dialog;
 197         if (owner instanceof Frame) {
 198             dialog = new ServiceDialog(gc,
 199                                        x + gcBounds.x,
 200                                        y + gcBounds.y,
 201                                        services, defaultIndex,
 202                                        flavor, attributes,
 203                                        (Frame)owner);
 204         } else {
 205             dialog = new ServiceDialog(gc,
 206                                        x + gcBounds.x,
 207                                        y + gcBounds.y,
 208                                        services, defaultIndex,
 209                                        flavor, attributes,
 210                                        (Dialog)owner);
 211         }
 212         Rectangle dlgBounds = dialog.getBounds();
 213 
 214         // get union of all GC bounds
 215         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
 216         GraphicsDevice[] gs = ge.getScreenDevices();
 217         for (int j=0; j<gs.length; j++) {
 218             gcBounds =
 219                 gcBounds.union(gs[j].getDefaultConfiguration().getBounds());
 220         }
 221 
 222         // if portion of dialog is not within the gc boundary
 223         if (!gcBounds.contains(dlgBounds)) {
 224             // put in the center relative to parent frame/dialog
 225             dialog.setLocationRelativeTo(owner);



















 226         }
 227         dialog.show();
 228 
 229         if (dialog.getStatus() == ServiceDialog.APPROVE) {
 230             PrintRequestAttributeSet newas = dialog.getAttributes();
 231             Class<?> dstCategory = Destination.class;
 232             Class<?> amCategory = SunAlternateMedia.class;
 233             Class<?> fdCategory = Fidelity.class;
 234 
 235             if (attributes.containsKey(dstCategory) &&
 236                 !newas.containsKey(dstCategory))
 237             {
 238                 attributes.remove(dstCategory);
 239             }
 240 
 241             if (attributes.containsKey(amCategory) &&
 242                 !newas.containsKey(amCategory))
 243             {
 244                 attributes.remove(amCategory);
 245             }




 176                     break;
 177                 }
 178             }
 179 
 180             if (defaultIndex < 0) {
 181                 throw new IllegalArgumentException("services must contain " +
 182                                                    "defaultService");
 183             }
 184         } else {
 185             defaultIndex = 0;
 186         }
 187 
 188         // For now we set owner to null. In the future, it may be passed
 189         // as an argument.
 190         Window owner = null;
 191 
 192         Rectangle gcBounds = (gc == null) ?  GraphicsEnvironment.
 193             getLocalGraphicsEnvironment().getDefaultScreenDevice().
 194             getDefaultConfiguration().getBounds() : gc.getBounds();
 195 
 196         x += gcBounds.x;
 197         y += gcBounds.y;
 198         ServiceDialog dialog;
 199         if (owner instanceof Frame) {
 200             dialog = new ServiceDialog(gc,
 201                                        x,
 202                                        y,
 203                                        services, defaultIndex,
 204                                        flavor, attributes,
 205                                        (Frame)owner);
 206         } else {
 207             dialog = new ServiceDialog(gc,
 208                                        x,
 209                                        y,
 210                                        services, defaultIndex,
 211                                        flavor, attributes,
 212                                        (Dialog)owner);
 213         }
 214         Rectangle dlgBounds = dialog.getBounds();
 215         








 216         // if portion of dialog is not within the gc boundary
 217         if (!gcBounds.contains(dlgBounds)) {
 218             
 219             // check if dialog exceed window bounds at left or bottom
 220             // Then position the dialog by moving it by the amount it exceeds 
 221             // the window bounds
 222             // If it results in dialog moving beyond the window bounds at top/left
 223             // then position it at window top/left
 224             if (dlgBounds.x + dlgBounds.width > gcBounds.x + gcBounds.width) {
 225                 if ((gcBounds.x + gcBounds.width - dlgBounds.width) > gcBounds.x) {
 226                     x = (gcBounds.x + gcBounds.width) - dlgBounds.width;                
 227                 } else {
 228                     x = gcBounds.x;                
 229                 }
 230             }
 231             if (dlgBounds.y + dlgBounds.height > gcBounds.y + gcBounds.height) {
 232                 if ((gcBounds.y + gcBounds.height - dlgBounds.height) > gcBounds.y) {
 233                     y = (gcBounds.y + gcBounds.height) - dlgBounds.height;                
 234                 } else {
 235                     y = gcBounds.y;
 236                 }
 237             }            
 238             dialog.setBounds(x, y, dlgBounds.width, dlgBounds.height);
 239         }
 240         dialog.show();
 241 
 242         if (dialog.getStatus() == ServiceDialog.APPROVE) {
 243             PrintRequestAttributeSet newas = dialog.getAttributes();
 244             Class<?> dstCategory = Destination.class;
 245             Class<?> amCategory = SunAlternateMedia.class;
 246             Class<?> fdCategory = Fidelity.class;
 247 
 248             if (attributes.containsKey(dstCategory) &&
 249                 !newas.containsKey(dstCategory))
 250             {
 251                 attributes.remove(dstCategory);
 252             }
 253 
 254             if (attributes.containsKey(amCategory) &&
 255                 !newas.containsKey(amCategory))
 256             {
 257                 attributes.remove(amCategory);
 258             }


< prev index next >