public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   if ("export_excel_file".equals(cmd)) // $NON-NLS-1$
   {
     try {
       ExcelExport export = new ExcelExport(application);
       export.showFrame();
     } catch (Exception ex) {
       application.reportError(
           Messages.getString("servoy.plugin.export.exception"), ex); // $NON-NLS-1$
     }
   } else if ("import_excel_file".equals(cmd)) // $NON-NLS-1$
   {
     try {
       ExcelImport importer = new ExcelImport(application);
       importer.showFrame();
     } catch (Exception ex) {
       application.reportError(
           Messages.getString("servoy.plugin.import.exception"), ex); // $NON-NLS-1$
     }
   }
 }
  public static void startPrinting(
      IApplication application,
      Pageable pageable,
      PrinterJob a_printerJob,
      String a_preferredPrinterName,
      boolean showPrinterSelectDialog,
      boolean avoidDialogs) {
    RepaintManager currentManager =
        RepaintManager.currentManager(application.getPrintingRendererParent().getParent());
    boolean isDoubleBufferingEnabled = false;
    try {
      if (currentManager != null) {
        isDoubleBufferingEnabled = currentManager.isDoubleBufferingEnabled();
      }

      if (a_printerJob != null) {
        // for plugin printing
        a_printerJob.setPageable(pageable);
        a_printerJob.setJobName("Servoy Print"); // $NON-NLS-1$
        if (showPrinterSelectDialog) {
          if (!a_printerJob.printDialog()) {
            return;
          }
          SwingHelper.dispatchEvents(100); // hide dialog
        }
        if (currentManager != null) {
          currentManager.setDoubleBufferingEnabled(false);
        }
        a_printerJob.print();
      } else {
        // by default we use old system for mac, new is not always working
        boolean useSystemPrintDialog =
            Utils.getAsBoolean(
                application
                    .getSettings()
                    .getProperty(
                        "useSystemPrintDialog",
                        "" + Utils.isAppleMacOS())); // $NON-NLS-1$//$NON-NLS-2$
        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
        PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
        if (capablePrintServices == null) {
          capablePrintServices = PrintServiceLookup.lookupPrintServices(flavor, pras);
        }

        PrintService service = null;
        if (capablePrintServices == null || capablePrintServices.length == 0) {
          if (avoidDialogs) {
            Debug.warn("Cannot find capable print services. Print aborted.");
            return;
          } else {
            JOptionPane.showConfirmDialog(
                ((ISmartClientApplication) application).getMainApplicationFrame(),
                application.getI18NMessage("servoy.print.msg.noPrintersFound"),
                application.getI18NMessage(
                    "servoy.print.printing.title"), //$NON-NLS-1$ //$NON-NLS-2$
                JOptionPane.OK_OPTION,
                JOptionPane.ERROR_MESSAGE);
            capablePrintServices = new PrintService[0];
            showPrinterSelectDialog = true; // must show select printer and if none found show this
            useSystemPrintDialog =
                true; // we leave to system to show no printers are found, important for apple mac
          }
        } else {
          service = capablePrintServices[0]; // default select
        }

        PrintService systemDefaultPrinter = PrintServiceLookup.lookupDefaultPrintService();
        if (systemDefaultPrinter != null) {
          // check if system default printer is in capable list
          for (PrintService ps : capablePrintServices) {
            if (ps.getName().equalsIgnoreCase(systemDefaultPrinter.getName())) {
              service = systemDefaultPrinter;
              break;
            }
          }
        }

        boolean didFindPrinter = true; // want custom preferred printer
        if (a_preferredPrinterName != null) {
          didFindPrinter = false;
          for (PrintService ps : capablePrintServices) {
            if (ps.getName().equalsIgnoreCase(a_preferredPrinterName)) {
              didFindPrinter = true;
              service = ps;
              break;
            }
          }
        }

        if (!didFindPrinter) {
          if (avoidDialogs) {
            Debug.warn(
                "Cannot find capable printer for preferred form printer name '"
                    + a_preferredPrinterName
                    + "'. Trying to use default/any capable printer.");
          } else {
            showPrinterSelectDialog = true; // did not found the prefered , do show
          }
        }

        if (!useSystemPrintDialog) {
          if (showPrinterSelectDialog) {
            JFrame frame = ((ISmartClientApplication) application).getMainApplicationFrame();
            GraphicsConfiguration gc = frame.getGraphicsConfiguration();
            Point loc = frame.getLocation();
            service =
                ServiceUI.printDialog(
                    gc, loc.x + 50, loc.y + 50, capablePrintServices, service, flavor, pras);
          }
          if (service != null) {
            if (currentManager != null) {
              currentManager.setDoubleBufferingEnabled(false);
            }
            DocPrintJob job = service.createPrintJob();
            DocAttributeSet das = new HashDocAttributeSet();
            Doc doc = new SimpleDoc(pageable, flavor, das);
            if (job != null) {
              job.print(doc, pras);
            } else {
              // for example if the print service cancels (e.g. print to pdf and then user cancel
              // when choosing save location)
              application.reportWarning(
                  application.getI18NMessage(
                      "servoy.print.error.cannotPrintDocument")); //$NON-NLS-1$
            }
          }
        } else {
          a_printerJob = PrinterJob.getPrinterJob();
          a_printerJob.setPageable(pageable);
          a_printerJob.setJobName("Servoy Print"); // $NON-NLS-1$
          if (service != null) {
            a_printerJob.setPrintService(service);
          }
          if (showPrinterSelectDialog) {
            if (!a_printerJob.printDialog()) {
              return;
            }
            SwingHelper.dispatchEvents(100); // hide dialog
          }
          if (currentManager != null) {
            currentManager.setDoubleBufferingEnabled(false);
          }
          a_printerJob.print();
        }
      }
    } catch (Exception ex) {
      application.reportError(
          application.getI18NMessage("servoy.print.error.cannotPrintDocument"), ex); // $NON-NLS-1$
    } finally {
      if (currentManager != null) {
        currentManager.setDoubleBufferingEnabled(isDoubleBufferingEnabled);
      }
    }
  }