Exemple #1
0
 void showCompanion(boolean switchTabs) {
   CompanionFacade companion = getSelectedCompanion();
   if (companion == null) {
     if (!switchTabs) {
       infoPane.setText(""); // $NON-NLS-1$
     }
     return;
   }
   if (isCompanionOpen(companion)) {
     CharacterFacade character = CharacterManager.getCharacterMatching(companion);
     if (character != null) {
       if (switchTabs) {
         frame.setSelectedCharacter(character);
         return;
       } else {
         sheetSupport.setCharacter(character);
         sheetSupport.refresh();
       }
     }
     // the companion was not found
     // TODO: show error, complain?
   } else if (switchTabs) {
     frame.loadCharacterFromFile(companion.getFileRef().getReference());
   } else {
     // Display a message telling the user to open the companion.
     infoPane.setText(
         LanguageBundle.getString("in_companionLoadCompanionMessage")); // $NON-NLS-1$
   }
 }
 @Override
 public void actionPerformed(ActionEvent e) {
   if (SHEET_COMMAND.equals(e.getActionCommand())) {
     new PreviewLoader((URI) sheetBox.getSelectedItem()).execute();
   } else if (PAGE_COMMAND.equals(e.getActionCommand())) {
     previewPanel.setPage(pageBox.getSelectedIndex());
   } else if (ZOOM_COMMAND.equals(e.getActionCommand())) {
     Double zoom = (Double) zoomBox.getSelectedItem();
     previewPanel.setScaleFactor(zoom);
   } else if (ZOOM_IN_COMMAND.equals(e.getActionCommand())) {
     Double zoom = (Double) zoomBox.getSelectedItem();
     zoomBox.setSelectedItem(zoom * ZOOM_MULTIPLIER);
   } else if (ZOOM_OUT_COMMAND.equals(e.getActionCommand())) {
     Double zoom = (Double) zoomBox.getSelectedItem();
     zoomBox.setSelectedItem(zoom / ZOOM_MULTIPLIER);
   } else if (PRINT_COMMAND.equals(e.getActionCommand())) {
     PrinterJob printerJob = PrinterJob.getPrinterJob();
     printerJob.setPageable(pageable);
     if (printerJob.printDialog()) {
       try {
         printerJob.print();
         dispose();
       } catch (PrinterException ex) {
         String message = "Could not print " + character.getNameRef().get();
         Logging.errorPrint(message, ex);
         frame.showErrorMessage(Constants.APPLICATION_NAME, message);
       }
     }
   } else if (CANCEL_COMMAND.equals(e.getActionCommand())) {
     dispose();
   }
 }
 private PrintPreviewDialog(PCGenFrame frame) {
   super(frame, true);
   this.frame = frame;
   this.character = frame.getSelectedCharacterRef().get();
   this.previewPanelParent = new JPanel(new GridLayout(1, 1));
   this.sheetBox = new JComboBox();
   this.progressBar = new JProgressBar();
   this.pageBox = new JComboBox();
   this.zoomBox = new JComboBox();
   this.zoomInButton = new JButton();
   this.zoomOutButton = new JButton();
   this.printButton = new JButton();
   this.cancelButton = new JButton();
   initComponents();
   initLayout();
   pack();
   new SheetLoader().execute();
 }