use of com.servoy.j2db.printing.PrintPreview in project servoy-client by Servoy.
the class SwingFormManager method showPreview.
@Override
public void showPreview(final FormController afp, final IFoundSetInternal foundset, int zoomFactor, final PrinterJob printJob) {
removePreview();
final FormController fc = currentContainer.getController();
if (fc != null) {
List invokeLaterRunnables = new ArrayList();
boolean ok = fc.notifyVisible(false, invokeLaterRunnables);
Utils.invokeLater(getApplication(), invokeLaterRunnables);
if (!ok) {
// cannot hide...so skip preview
return;
}
}
showFormInMainPanel(afp.getName(), currentContainer, null, true, null);
getApplication().getModeManager().setMode(IModeManager.PREVIEW_MODE);
boolean isNewUser = checkAndUpdateFormUser(afp, currentContainer);
if (isNewUser) {
IFormUIInternal ui = afp.getFormUI();
currentContainer.add(ui, afp.getName());
}
try {
final PrintPreview printPreview = new PrintPreview((ISmartClientApplication) getApplication(), afp, foundset, zoomFactor, printJob);
Runnable r = new Runnable() {
public void run() {
printPreviews.put(currentContainer, new PrintPreviewHolder(printPreview, fc));
// $NON-NLS-1$
currentContainer.add(printPreview, "@preview");
// $NON-NLS-1$
currentContainer.show("@preview");
// handle navigator propertly
List invokeLaterRunnables = new ArrayList();
afp.showNavigator(invokeLaterRunnables);
Utils.invokeLater(getApplication(), invokeLaterRunnables);
printPreview.showPages();
}
};
getApplication().invokeLater(r);
} catch (Exception ex) {
// $NON-NLS-1$
getApplication().reportError(Messages.getString("servoy.formManager.error.PrintPreview"), ex);
}
}
Aggregations