Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 97467 Details for
Bug 227373
[Printing] Remove experimental printing menu item and enable real menu for multi platform printing.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
combined patch
Printing_Combined_1.patch (text/plain), 61.26 KB, created by
James Bruck
on 2008-04-24 10:39:05 EDT
(
hide
)
Description:
combined patch
Filename:
MIME Type:
Creator:
James Bruck
Created:
2008-04-24 10:39:05 EDT
Size:
61.26 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.common.ui.action >Index: src/org/eclipse/gmf/runtime/common/ui/action/actions/global/GlobalPrintAction.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.common.ui.action/src/org/eclipse/gmf/runtime/common/ui/action/actions/global/GlobalPrintAction.java,v >retrieving revision 1.7 >diff -u -r1.7 GlobalPrintAction.java >--- src/org/eclipse/gmf/runtime/common/ui/action/actions/global/GlobalPrintAction.java 7 Mar 2008 16:51:38 -0000 1.7 >+++ src/org/eclipse/gmf/runtime/common/ui/action/actions/global/GlobalPrintAction.java 24 Apr 2008 14:00:47 -0000 >@@ -87,11 +87,7 @@ > * @see org.eclipse.gmf.runtime.common.ui.action.IRepeatableAction#refresh() > */ > public void refresh() { >- // >- // In phase 2 of printing enhancements we will remove the OS restriction. >- // >- setEnabled(!getGlobalActionHandlerData().isEmpty() && System.getProperty("os.name").toUpperCase().startsWith("WIN")); //$NON-NLS-1$ //$NON-NLS-2$ >- >+ setEnabled(!getGlobalActionHandlerData().isEmpty()); //$NON-NLS-1$ //$NON-NLS-2$ > } > > /* (non-Javadoc) >#P org.eclipse.gmf.runtime.diagram.ui.printing.render >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinterHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinterHelper.java,v >retrieving revision 1.2 >diff -u -r1.2 JPSDiagramPrinterHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinterHelper.java 31 Mar 2008 15:00:56 -0000 1.2 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinterHelper.java 24 Apr 2008 14:00:48 -0000 >@@ -42,7 +42,6 @@ > * This class uses the java print service API to accomplish its task. > * This class was derived from @see org.eclipse.gmf.runtime.diagram.ui.printing.util.DiagramPrinterUtil > * >- * This class is subject to change/removal during phase 2 of printing enhancements > * > * @author James Bruck (jbruck) > */ >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinter.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinter.java,v >retrieving revision 1.5 >diff -u -r1.5 JPSDiagramPrinter.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinter.java 4 Apr 2008 20:34:33 -0000 1.5 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/internal/JPSDiagramPrinter.java 24 Apr 2008 14:00:48 -0000 >@@ -82,12 +82,14 @@ > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.PlatformUI; > > /** > * This class supports printing using the Java Print Service API. The logic of >@@ -374,11 +376,12 @@ > try { > printGraphics.setClip(0, 0, (int) pageFormat.getWidth(), > (int) pageFormat.getHeight()); >+ > swtGraphics = new PrinterGraphicsToGraphics2DAdapter( > (java.awt.Graphics2D) printGraphics, new Rectangle(0, 0, > (int) pageFormat.getWidth(), (int) pageFormat > .getHeight())); >- >+ > graphics = createMapModeGraphics(createPrinterGraphics(swtGraphics)); > graphics.scale(AWT_DPI_CONST / display_dpi.x); > drawPage(pages[pageIndex]); >@@ -547,12 +550,45 @@ > * indicates which page to print. > */ > protected void drawPage(PageData page) { >+ > this.graphics.pushState(); > >- internalDrawPage(page.diagram, page.bounds, page.preferences, >- page.margins, graphics, page.row, page.column, false); >+ int shellStyle = PlatformUI.getWorkbench().getActiveWorkbenchWindow() >+ .getShell().getStyle(); >+ boolean rtlEnabled = (shellStyle & SWT.MIRRORED) != 0; >+ >+ if (rtlEnabled) { >+ >+ org.eclipse.draw2d.geometry.Point pageSize = PageInfoHelper >+ .getPageSize(page.preferences, false, getMapMode()); >+ >+ Image image = new Image(Display.getDefault(), getMapMode().LPtoDP( >+ pageSize.x), getMapMode().LPtoDP(pageSize.y)); >+ >+ GC imgGC = new GC(image, SWT.RIGHT_TO_LEFT); >+ SWTGraphics tempSWTGraphic = new SWTGraphics(imgGC); >+ ScaledGraphics tempScaledGraphic = new ScaledGraphics(tempSWTGraphic); >+ MapModeGraphics tempMapModeGraphic = createMapModeGraphics(tempScaledGraphic); >+ >+ imgGC.setFont(tempMapModeGraphic.getFont()); >+ >+ internalDrawPage(page.diagram, page.bounds, page.preferences, >+ page.margins, tempMapModeGraphic, page.row, page.column, true); >+ >+ this.graphics.drawImage(image, 0, 0); >+ >+ tempMapModeGraphic.dispose(); >+ tempScaledGraphic.dispose(); >+ tempSWTGraphic.dispose(); >+ imgGC.dispose(); >+ image.dispose(); >+ >+ } else { >+ >+ internalDrawPage(page.diagram, page.bounds, page.preferences, >+ page.margins, graphics, page.row, page.column, false); >+ } > >- // TODO: Re-enable printing of header and footer in phase 2 > this.graphics.popState(); > } > >@@ -584,8 +620,7 @@ > int scaledHeight = (int) (height / userScale); > > if (RTL_ENABLED) { >- scaledTranslateX += (margins.left * (colIndex - 1)) >- + (margins.right * (colIndex)); >+ scaledTranslateX += (margins.left * (colIndex - 1)) + (margins.right * (colIndex)); > scaledTranslateY += ((margins.top * rowIndex) + (margins.bottom * (rowIndex - 1))); > } else { > scaledTranslateX += ((margins.left * colIndex) + (margins.right * (colIndex - 1))); >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/ActionsBlock.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/ActionsBlock.java,v >retrieving revision 1.3 >diff -u -r1.3 ActionsBlock.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/ActionsBlock.java 4 Apr 2008 21:50:20 -0000 1.3 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/ActionsBlock.java 24 Apr 2008 14:00:48 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.gmf.runtime.common.ui.action.actions.IPrintActionHelper; > import org.eclipse.gmf.runtime.diagram.ui.printing.internal.l10n.DiagramUIPrintingMessages; > import org.eclipse.gmf.runtime.diagram.ui.printing.internal.printpreview.PrintPreviewHelper; >+import org.eclipse.gmf.runtime.diagram.ui.printing.internal.util.PrintHelperUtil; > import org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.EnhancedPrintActionHelper; > import org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.printpreview.RenderedPrintPreviewHelper; > import org.eclipse.gmf.runtime.diagram.ui.printing.render.model.PrintOptions; >@@ -75,9 +76,24 @@ > break; > default: > PrintPreviewHelper previewHelper = getPrintPreviewHelper(); >- previewHelper.setUserScale(options.getScaleFactor() / 100f); >+ >+ PrintHelperUtil.setScale(options.getScaleFactor()); >+ PrintHelperUtil.setScaleToWidth(options.getFitToPagesWidth()); >+ PrintHelperUtil.setScaleToHeight(options.getFitToPagesHeight()); > previewHelper.enablePrinting(false); >+ >+ if (options.isPercentScaling()) { >+ previewHelper.setPercentScaling(options.getScaleFactor()); >+ } else { >+ previewHelper.setFitToPage(options.getFitToPagesWidth(), >+ options.getFitToPagesHeight()); >+ } >+ > previewHelper.doPrintPreview(getPrintActionHelper()); >+ >+ options.setScaleFactor(PrintHelperUtil.getScale()); >+ options.setFitToPagesWidth(PrintHelperUtil.getScaleToWidth()); >+ options.setFitToPagesHeight(PrintHelperUtil.getScaleToHeight()); > } > } > >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DiagramPrintRangeBlock.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DiagramPrintRangeBlock.java,v >retrieving revision 1.1 >diff -u -r1.1 DiagramPrintRangeBlock.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DiagramPrintRangeBlock.java 4 Apr 2008 21:44:32 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DiagramPrintRangeBlock.java 24 Apr 2008 14:00:48 -0000 >@@ -80,7 +80,8 @@ > layoutSpanHorizontal(selectedDiagramsRadio, 4); > > diagramList = list(result); >- layoutFillHorizontal(diagramList.getControl()); >+ >+ layoutFillHorizontal(layoutHeight(diagramList.getControl(),48)); > diagramList.getControl().setEnabled(options.isDiagramSelection()); > > currentDiagramRadio.addSelectionListener(new SelectionListener() { >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/PrinterBlock.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/PrinterBlock.java,v >retrieving revision 1.3 >diff -u -r1.3 PrinterBlock.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/PrinterBlock.java 4 Apr 2008 21:44:32 -0000 1.3 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/PrinterBlock.java 24 Apr 2008 14:00:48 -0000 >@@ -142,12 +142,12 @@ > // resultCommentLabel = label(result, ""); > // layoutFillHorizontal(resultCommentLabel); > >- Button printToFile = check(result, >- DiagramUIPrintingMessages.JPSPrintDialog_PrintToFile); >- layoutSpanHorizontal(printToFile, 3); >- >- // TODO: implement in phase 2 >- printToFile.setEnabled(false); >+ // The Destination attribute is not IPP compatible. >+ >+ // Button printToFile = check(result, >+ // DiagramUIPrintingMessages.JPSPrintDialog_PrintToFile); >+ // layoutSpanHorizontal(printToFile, 3); >+ // printToFile.setEnabled(false); > > init(); > >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DialogBlock.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DialogBlock.java,v >retrieving revision 1.2 >diff -u -r1.2 DialogBlock.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DialogBlock.java 4 Apr 2008 21:44:32 -0000 1.2 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/dialogs/DialogBlock.java 24 Apr 2008 14:00:48 -0000 >@@ -169,6 +169,15 @@ > > return control; > } >+ >+ Control layoutHeight(Control control, int dlus) { >+ if (dlus > 0) { >+ GridData data = getLayoutData(control); >+ data.heightHint = dluConverter.convertHorizontalDLUsToPixels(dlus); >+ } >+ >+ return control; >+ } > > Group group(Composite parent, String text) { > Group result = new Group(parent, SWT.NONE); >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/actions/EnhancedPrintActionHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/actions/EnhancedPrintActionHelper.java,v >retrieving revision 1.4 >diff -u -r1.4 EnhancedPrintActionHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/actions/EnhancedPrintActionHelper.java 7 Mar 2008 16:51:30 -0000 1.4 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/actions/EnhancedPrintActionHelper.java 24 Apr 2008 14:00:48 -0000 >@@ -89,16 +89,12 @@ > IMapMode mapMode = (rootEP instanceof DiagramRootEditPart) ? ((DiagramRootEditPart) rootEP) > .getMapMode() > : MapModeUtil.getMapMode(); >- // >- // Eventually the windows based printing will be replaced with the >- // JPSDiagramPrinter. >- // >+ > if (Platform.getOS().startsWith(Platform.OS_WIN32)) { > DiagramPrinterUtil.printWithSettings(diagramEditor, > createDiagramMap(), new RenderedDiagramPrinter( > preferencesHint, mapMode)); >- } >- else { >+ } else { > JPSDiagramPrinterHelper.getDiagramPrinterHelper() > .printWithSettings(diagramEditor, createDiagramMap(), > new JPSDiagramPrinter(preferencesHint, mapMode)); >@@ -106,12 +102,12 @@ > } > > /** >- * Return a Map with diagram name String as key and Diagram as value >- * All entries in the map correspond to open editors. >+ * Return a Map with diagram name String as key and Diagram as value All >+ * entries in the map correspond to open editors. > * >- * @return Map with diagram name String as key and Diagram as value >- * All entries in the map correspond to open editors with the >- * diagramEditor's id. >+ * @return Map with diagram name String as key and Diagram as value All >+ * entries in the map correspond to open editors with the >+ * diagramEditor's id. > */ > protected Map<String, Diagram> createDiagramMap() { > >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/render/util/PrintHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing.render/src/org/eclipse/gmf/runtime/diagram/ui/printing/render/util/PrintHelper.java,v >retrieving revision 1.3 >diff -u -r1.3 PrintHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/render/util/PrintHelper.java 4 Apr 2008 21:44:32 -0000 1.3 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/render/util/PrintHelper.java 24 Apr 2008 14:00:48 -0000 >@@ -14,6 +14,7 @@ > import java.util.List; > > import org.eclipse.gmf.runtime.common.ui.printing.IPrintHelper; >+import org.eclipse.gmf.runtime.diagram.ui.printing.internal.util.PrintHelperUtil; > import org.eclipse.gmf.runtime.diagram.ui.printing.render.dialogs.JPSPrintDialog; > import org.eclipse.gmf.runtime.diagram.ui.printing.render.model.PrintOptions; > import org.eclipse.jface.dialogs.IDialogConstants; >@@ -40,9 +41,10 @@ > */ > private void initPrintOptions() { > options.setPercentScaling(true); >- options.setScaleFactor(100); >- options.setFitToPagesWidth(1); >- options.setFitToPagesHeight(1); >+ >+ options.setScaleFactor(PrintHelperUtil.getScale()); >+ options.setFitToPagesWidth(PrintHelperUtil.getScaleToWidth()); >+ options.setFitToPagesHeight(PrintHelperUtil.getScaleToHeight()); > > options.setAllPages(true); > options.setRangeFrom(1); >@@ -149,5 +151,16 @@ > public PrintOptions getPrintOptions() { > return options; > } >+ >+ @Override >+ public void setScaleFactor(int scaleFactor) { >+ options.setScaleFactor(scaleFactor) ; >+ } >+ >+ @Override >+ public void setScaleToWidthHeight(int width, int height) { >+ options.setFitToPagesWidth(width); >+ options.setFitToPagesHeight(height); >+ } > > } >#P org.eclipse.gmf.runtime.common.ui.printing.win32 >Index: src/org/eclipse/gmf/runtime/common/ui/printing/PrintHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.common.ui.printing.win32/src/org/eclipse/gmf/runtime/common/ui/printing/PrintHelper.java,v >retrieving revision 1.6 >diff -u -r1.6 PrintHelper.java >--- src/org/eclipse/gmf/runtime/common/ui/printing/PrintHelper.java 6 Oct 2006 13:33:08 -0000 1.6 >+++ src/org/eclipse/gmf/runtime/common/ui/printing/PrintHelper.java 24 Apr 2008 14:00:49 -0000 >@@ -16,15 +16,14 @@ > import java.util.List; > import java.util.Locale; > >-import org.eclipse.swt.printing.PrinterData; >-import org.eclipse.ui.PlatformUI; >- > import org.eclipse.gmf.runtime.common.core.util.Log; > import org.eclipse.gmf.runtime.common.core.util.StringStatics; > import org.eclipse.gmf.runtime.common.core.util.Trace; > import org.eclipse.gmf.runtime.common.ui.printing.internal.CommonPrintingDebugOptions; > import org.eclipse.gmf.runtime.common.ui.printing.internal.CommonPrintingStatusCodes; > import org.eclipse.gmf.runtime.common.ui.printing.internal.PrintingPlugin; >+import org.eclipse.swt.printing.PrinterData; >+import org.eclipse.ui.PlatformUI; > > /** > * The PrintHelper implements the IPrintHelper interface for the platform >@@ -323,9 +322,7 @@ > > // initialize dialog > resetDialog(); >- initScaleFitTo(1, 1); >- initScalePercent(100); >- >+ > if (diagramList != null) { > for (int c = 0; c < diagramList.size(); c++) { > assert (diagramList.get(c) instanceof String); >@@ -521,5 +518,21 @@ > public void setDlgPaperSize(int index, double width, double height) { > setPaperSize(index, width, height); > } >+ >+ /** >+ * Initialize the scaling factor in the print dialog. >+ */ >+ @Override >+ public void setScaleFactor(int scaleFactor) { >+ initScalePercent(scaleFactor); >+ } >+ >+ /** >+ * Initialize the scale width and height in the print dialog. >+ */ >+ @Override >+ public void setScaleToWidthHeight(int width, int height) { >+ initScaleFitTo(width, height); >+ } > > } >\ No newline at end of file >#P org.eclipse.gmf.runtime.diagram.ui.render >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.render/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 28 Mar 2008 17:33:30 -0000 1.6 >+++ plugin.xml 24 Apr 2008 14:00:50 -0000 >@@ -23,22 +23,6 @@ > </editpartProvider> > </extension> > >- <extension id="printingExperimentalContributionItemProvider" name="Printing_Experimental" point="org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders"> >- <contributionItemProvider >- checkPluginLoaded="false" >- class="org.eclipse.gmf.runtime.diagram.ui.render.internal.providers.PrintingExperimentalContributionItemProvider"> >- <Priority name="Medium"> >- </Priority> >- <partContribution class="org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart"> >- <partAction >- global="true" >- id="printExperimentalAction" >- menubarPath="/file/print"> >- </partAction> >- </partContribution> >- </contributionItemProvider> >- </extension> >- > <extension id="DiagramUIRenderContributionItemProvider" name="%ContributionItemProvider.name" point="org.eclipse.gmf.runtime.common.ui.services.action.contributionItemProviders"> > <contributionItemProvider class="org.eclipse.gmf.runtime.diagram.ui.render.internal.providers.DiagramUIRenderContributionItemProvider"> > <Priority name="Low"> >Index: src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintExperimentalAction.java >=================================================================== >RCS file: src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintExperimentalAction.java >diff -N src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintExperimentalAction.java >--- src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintExperimentalAction.java 7 Mar 2008 16:51:31 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,138 +0,0 @@ >-/****************************************************************************** >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ****************************************************************************/ >- >-package org.eclipse.gmf.runtime.diagram.ui.render.internal.providers; >- >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.gef.RootEditPart; >-import org.eclipse.gmf.runtime.common.core.util.Log; >-import org.eclipse.gmf.runtime.common.core.util.Trace; >-import org.eclipse.gmf.runtime.common.ui.action.actions.IPrintActionHelper; >-import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart; >-import org.eclipse.gmf.runtime.diagram.ui.editparts.IDiagramPreferenceSupport; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; >-import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer; >-import org.eclipse.gmf.runtime.diagram.ui.printing.render.actions.EnhancedPrintActionHelper; >-import org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.DiagramUIPrintingRenderDebugOptions; >-import org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.DiagramUIPrintingRenderPlugin; >-import org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.JPSDiagramPrinter; >-import org.eclipse.gmf.runtime.diagram.ui.printing.render.internal.JPSDiagramPrinterHelper; >-import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; >-import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; >-import org.eclipse.jface.action.Action; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.IWorkbenchWindow; >-import org.eclipse.ui.IWorkbenchWindowActionDelegate; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * This class is strictly temporary while we introduce the printing via the >- * Print Service API. >- * >- * @author James Bruck (jbruck) >- */ >-public class PrintExperimentalAction extends Action implements >- IWorkbenchWindowActionDelegate { >- >- /** >- * ID for this page setup action >- */ >- public static final String ID = "printExperimentalAction";//$NON-NLS-1$ >- >- /** >- * Constructor sets the id and label that is displayed in the menu bar. >- */ >- public PrintExperimentalAction() { >- setId(ID); >- setText("Print (Experimental)..."); //$NON-NLS-1$ >- } >- >- /** >- * We override the print to always use the newer JPS printing options. >- */ >- public void run() { >- >- IPrintActionHelper helper = new EnhancedPrintActionHelper() { >- @Override >- public void doPrint(IWorkbenchPart workbenchPart) { >- >- DiagramEditor diagramEditor = null; >- >- if (workbenchPart instanceof DiagramEditor) { >- diagramEditor = (DiagramEditor) workbenchPart; >- } else { >- Log.error(DiagramUIPrintingRenderPlugin.getInstance(), >- IStatus.ERROR, "Invalid IWorkbenchPart"); //$NON-NLS-1$ >- IllegalArgumentException e = new IllegalArgumentException( >- "Invalid IWorkbenchPart."); //$NON-NLS-1$ >- Trace >- .throwing( >- DiagramUIPrintingRenderPlugin.getInstance(), >- DiagramUIPrintingRenderDebugOptions.EXCEPTIONS_THROWING, >- EnhancedPrintActionHelper.class, >- "doPrint()", e); //$NON-NLS-1$ >- throw e; >- } >- >- IDiagramGraphicalViewer viewer = diagramEditor >- .getDiagramGraphicalViewer(); >- RootEditPart rootEP = (viewer == null) ? null : viewer >- .getRootEditPart(); >- PreferencesHint preferencesHint = (rootEP instanceof IDiagramPreferenceSupport) ? ((IDiagramPreferenceSupport) rootEP) >- .getPreferencesHint() >- : PreferencesHint.USE_DEFAULTS; >- >- IMapMode mapMode = (rootEP instanceof DiagramRootEditPart) ? ((DiagramRootEditPart) rootEP) >- .getMapMode() >- : MapModeUtil.getMapMode(); >- >- JPSDiagramPrinterHelper >- .getDiagramPrinterHelper() >- .printWithSettings(diagramEditor, createDiagramMap(), >- new JPSDiagramPrinter(preferencesHint, mapMode)); >- } >- }; >- >- helper.doPrint(PlatformUI.getWorkbench().getActiveWorkbenchWindow() >- .getActivePage().getActivePart()); >- } >- >- /** >- * The run method does the real run action. From IActionDelegate >- */ >- public void run(IAction action) { >- run(); >- } >- >- /** >- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose() >- */ >- public void dispose() { >- // do nothing >- } >- >- /** >- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow) >- */ >- public void init(IWorkbenchWindow window) { >- // do nothing >- } >- >- /** >- * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) >- */ >- public void selectionChanged(IAction action, ISelection selection) { >- //do nothing >- } >-} >Index: src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintingExperimentalContributionItemProvider.java >=================================================================== >RCS file: src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintingExperimentalContributionItemProvider.java >diff -N src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintingExperimentalContributionItemProvider.java >--- src/org/eclipse/gmf/runtime/diagram/ui/render/internal/providers/PrintingExperimentalContributionItemProvider.java 7 Mar 2008 16:51:31 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,40 +0,0 @@ >-/****************************************************************************** >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- ****************************************************************************/ >- >-package org.eclipse.gmf.runtime.diagram.ui.render.internal.providers; >- >-import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider; >-import org.eclipse.gmf.runtime.common.ui.util.IWorkbenchPartDescriptor; >-import org.eclipse.jface.action.IAction; >- >- >-/** >- * This class is strictly temporary while we introduce the printing via the >- * Print Service API. >- * >- * @author James Bruck (jbruck) >- */ >-public class PrintingExperimentalContributionItemProvider extends >- AbstractContributionItemProvider { >- >- /** >- * @see org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.AbstractContributionItemProvider#createAction(java.lang.String, org.eclipse.gmf.runtime.common.ui.services.contributionitem.IWorkbenchPartDescriptor) >- */ >- protected IAction createAction( >- String actionId, >- IWorkbenchPartDescriptor partDescriptor) { >- >- if (actionId.equals(PrintExperimentalAction.ID)) >- return new PrintExperimentalAction(); >- >- return super.createAction(actionId, partDescriptor); >- } >-} >#P org.eclipse.gmf.runtime.common.ui.printing >Index: src/org/eclipse/gmf/runtime/common/ui/printing/IPrintHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.common.ui.printing/src/org/eclipse/gmf/runtime/common/ui/printing/IPrintHelper.java,v >retrieving revision 1.3 >diff -u -r1.3 IPrintHelper.java >--- src/org/eclipse/gmf/runtime/common/ui/printing/IPrintHelper.java 3 Oct 2006 14:54:47 -0000 1.3 >+++ src/org/eclipse/gmf/runtime/common/ui/printing/IPrintHelper.java 24 Apr 2008 14:00:52 -0000 >@@ -152,4 +152,21 @@ > */ > void setDlgPaperSize(int index, double width, double length); > >+ /** >+ * Preserve the scale factor that the user enters in the preview or print >+ * dialogs. >+ * >+ * @param scaleFactor a zoom factor integer value greater than 0. >+ */ >+ void setScaleFactor(int scaleFactor); >+ >+ /** >+ * Preserve the width and height scale factors >+ * >+ * @param width scale to number of pages wide >+ * @param height scale to number of pages high >+ */ >+ void setScaleToWidthHeight(int width, int height); >+ >+ > } >#P org.eclipse.gmf.runtime.diagram.ui.printing >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/PrintHelperUtil.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/PrintHelperUtil.java,v >retrieving revision 1.1 >diff -u -r1.1 PrintHelperUtil.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/PrintHelperUtil.java 7 Mar 2008 16:51:34 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/PrintHelperUtil.java 24 Apr 2008 14:00:53 -0000 >@@ -37,12 +37,45 @@ > import org.eclipse.swt.widgets.Shell; > > /** >- * Helper to assist in making an offscreen diagram suitable for printing or >+ * Helper to assist in making an off screen diagram suitable for printing or > * previewing. > * > * @author James Bruck (jbruck) > */ > public class PrintHelperUtil { >+ >+ // >+ // The following printing attributes are saved across >+ // the preview and print dialogs. >+ // >+ private static int scaleFactor = 100; >+ private static int scaleWidth = 1; >+ private static int scaleHeight = 1; >+ >+ public static int getScale() { >+ return scaleFactor; >+ } >+ >+ public static void setScale(int scale) { >+ scaleFactor = scale; >+ } >+ >+ public static int getScaleToWidth() { >+ return scaleWidth; >+ } >+ >+ public static void setScaleToWidth(int width) { >+ scaleWidth = width; >+ } >+ >+ public static int getScaleToHeight() { >+ return scaleHeight; >+ } >+ >+ public static void setScaleToHeight(int height) { >+ scaleHeight = height; >+ } >+ > /** > * Creates a <code>DiagramEditPart</code> given the <code>Diagram</code> > * without opening an editor. >@@ -293,4 +326,5 @@ > > return pageBreakBounds; > } >+ > } >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinterHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinterHelper.java,v >retrieving revision 1.1 >diff -u -r1.1 DiagramPrinterHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinterHelper.java 7 Mar 2008 16:51:34 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinterHelper.java 24 Apr 2008 14:00:53 -0000 >@@ -37,10 +37,8 @@ > * > * Basic functionality was factored into this class from the DiagramPrinterUtil. > * This class and its specializing classes: >- * JPSDiagramPrinterHelper and SWTDiagramPrinterHelper will be subject to change >- * during phase 2 of printing enhancement changes. > * >- * @author jbruck >+ * @author James Bruck (jbruck) > */ > public class DiagramPrinterHelper { > >@@ -160,10 +158,24 @@ > } else { > helper.setDlgPaperSize(storedPageType.getIndex(), 0, 0); > } >- } >+ } >+ helper.setScaleFactor(PrintHelperUtil.getScale()); >+ helper.setScaleToWidthHeight(PrintHelperUtil.getScaleToWidth(), PrintHelperUtil.getScaleToHeight()); > > printerData = helper.openPrintDlg(diagramNames); > >+ if (printerData != null) { >+ if (helper.getDlgScalePercent() != -1) { >+ PrintHelperUtil.setScale(helper.getDlgScalePercent()); >+ } >+ if (helper.getDlgScaleFitToM() != -1) { >+ PrintHelperUtil.setScaleToWidth(helper.getDlgScaleFitToM()); >+ } >+ if (helper.getDlgScaleFitToN() != -1) { >+ PrintHelperUtil.setScaleToHeight(helper.getDlgScaleFitToN()); >+ } >+ } >+ > return printerData; > } > >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinter.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinter.java,v >retrieving revision 1.15 >diff -u -r1.15 DiagramPrinter.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinter.java 7 Mar 2008 16:51:34 -0000 1.15 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/DiagramPrinter.java 24 Apr 2008 14:00:53 -0000 >@@ -31,7 +31,7 @@ > * Basic page calculation operations have been factored out into this class. > * This class was derived from the previous DiagramPrinter. > * >- * @author James Bruck (jbruck) >+ * @author Wayne Diu, wdiu > */ > public abstract class DiagramPrinter implements Runnable { > >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinterHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinterHelper.java,v >retrieving revision 1.1 >diff -u -r1.1 SWTDiagramPrinterHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinterHelper.java 7 Mar 2008 16:51:35 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinterHelper.java 24 Apr 2008 14:00:53 -0000 >@@ -40,13 +40,9 @@ > * and respect the settings chosen by the user in the print dialog. > * > * This class uses the SWT printing to accomplish its task. This class was >- * derived from >- * >+ * derived from > * @see org.eclipse.gmf.runtime.diagram.ui.printing.util.DiagramPrinterUtil >- * >- * This class is subject to change/removal during phase 2 of printing >- * enhancements >- * >+ * > * @author James Bruck (jbruck) > */ > public class SWTDiagramPrinterHelper extends DiagramPrinterHelper { >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinter.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinter.java,v >retrieving revision 1.1 >diff -u -r1.1 SWTDiagramPrinter.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinter.java 7 Mar 2008 16:51:34 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/util/SWTDiagramPrinter.java 24 Apr 2008 14:00:53 -0000 >@@ -52,7 +52,7 @@ > * This class supports printing using the SWT printing constructs. > * Much of the paging code was derived from the previous <code> DiagramPrinter </code>. > * >- * @author James Bruck (jbruck) >+ * @author Wayne Diu, wdiu > */ > public class SWTDiagramPrinter extends DiagramPrinter > implements Runnable { >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.java,v >retrieving revision 1.4 >diff -u -r1.4 DiagramUIPrintingMessages.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.java 4 Apr 2008 21:44:33 -0000 1.4 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.java 24 Apr 2008 14:00:53 -0000 >@@ -39,6 +39,8 @@ > public static String PrintPreview_4Up; > public static String PrintPreview_ActionLabel; > public static String PrintPreview_NoPrinterInstalled; >+ public static String PrintPreview_FitToPage_DialogTitle; >+ public static String PrintPreview_FitToPage_ButtonText; > public static String Print_MessageDialogTitle; > public static String Print_MessageDialogMessage; > public static String DiagramPrinterUtil_DLLErrorTitle; >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.properties >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.properties,v >retrieving revision 1.4 >diff -u -r1.4 DiagramUIPrintingMessages.properties >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.properties 4 Apr 2008 21:44:33 -0000 1.4 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/l10n/DiagramUIPrintingMessages.properties 24 Apr 2008 14:00:53 -0000 >@@ -29,7 +29,8 @@ > PrintPreview_4Up=4 up > PrintPreview_ActionLabel=Print Pre&view > PrintPreview_NoPrinterInstalled=Please install a printer before selecting Print Preview. >- >+PrintPreview_FitToPage_DialogTitle=Scale Settings >+PrintPreview_FitToPage_ButtonText=Fit To Pages... > Print_MessageDialogTitle=Print Diagram > Print_MessageDialogMessage=Print to fit the diagram? > >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/printpreview/PrintPreviewHelper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/printpreview/PrintPreviewHelper.java,v >retrieving revision 1.15 >diff -u -r1.15 PrintPreviewHelper.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/printpreview/PrintPreviewHelper.java 8 Apr 2008 02:16:31 -0000 1.15 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/internal/printpreview/PrintPreviewHelper.java 24 Apr 2008 14:00:53 -0000 >@@ -11,6 +11,8 @@ > > package org.eclipse.gmf.runtime.diagram.ui.printing.internal.printpreview; > >+ >+ > import java.util.ArrayList; > import java.util.List; > >@@ -31,6 +33,8 @@ > import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; > import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart; > import org.eclipse.gmf.runtime.diagram.ui.editparts.IDiagramPreferenceSupport; >+import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.PageBreakEditPart; >+import org.eclipse.gmf.runtime.diagram.ui.internal.figures.PageBreaksFigure; > import org.eclipse.gmf.runtime.diagram.ui.internal.pagesetup.PageInfoHelper; > import org.eclipse.gmf.runtime.diagram.ui.internal.pagesetup.PageInfoHelper.PageMargins; > import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties; >@@ -51,6 +55,7 @@ > import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; > import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; > import org.eclipse.gmf.runtime.notation.Diagram; >+import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.swt.SWT; >@@ -64,12 +69,16 @@ > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.MenuItem; > import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; > import org.eclipse.swt.widgets.ToolBar; > import org.eclipse.swt.widgets.ToolItem; > import org.eclipse.ui.IEditorPart; >@@ -80,10 +89,12 @@ > * methods, so you must create an instance of this class. > * > * Call doPrintPreview() after you've made an instance. >+ * >+ * This class should be combined with the DiagramPrinter to reuse functionality. > * > * @author Wayne Diu, wdiu > */ >-public class PrintPreviewHelper { >+public class PrintPreviewHelper{ > > /** > * Action helper for print. This must be passed in to have something happen >@@ -279,8 +290,14 @@ > > /** > * The print preview helper is capable of showing zoom input. >+ * userScale is a value between 0 and 1. > */ > protected double userScale = 1; >+ >+ /** >+ * Determine if we should consider fit to page options or not. >+ */ >+ private boolean fitToPage = false; > > /** > * Initialize all toolbar images >@@ -337,6 +354,8 @@ > public void doPrintPreview(IPrintActionHelper prActionHelper) { > this.printActionHelper = prActionHelper; > >+ setUserScale(PrintHelperUtil.getScale()); >+ > if (getDiagramEditorPart() == null) { > MessageDialog > .openInformation(PlatformUI.getWorkbench() >@@ -380,7 +399,7 @@ > > Display display = Display.getDefault(); > >- //check for rtl orientation... >+ //check for rtl Torientation... > int style = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getStyle(); > if ((style & SWT.MIRRORED) != 0) { > shell = new Shell(display, SWT.APPLICATION_MODAL | SWT.TITLE >@@ -413,6 +432,7 @@ > public void widgetSelected(SelectionEvent e) { > //should not be enabled > Assert.isNotNull(printActionHelper); >+ > printActionHelper > .doPrint(PlatformUI.getWorkbench() > .getActiveWorkbenchWindow().getActivePage() >@@ -470,11 +490,8 @@ > if (userY < 0) > userY = 0; > } >- >- updateLeftRightUpDownButtonsForToolbar(); >- >- updateCompositeForNumberOfColumns(numberOfRowsToDisplay, >- numberOfColumnsToDisplay); >+ >+ refreshComposite(); > > } > >@@ -553,9 +570,7 @@ > public void widgetSelected(SelectionEvent e) { > if (userX > 0) { > userX--; >- updateCompositeForNumberOfColumns(numberOfRowsToDisplay, >- numberOfColumnsToDisplay); >- updateLeftRightUpDownButtonsForToolbar(); >+ refreshComposite(); > } > } > >@@ -589,9 +604,7 @@ > //check for max pages to be safe > if (!(userX + numberOfColumnsToDisplay + 1 > getTotalNumberOfColumns())) { > userX++; >- updateCompositeForNumberOfColumns(numberOfRowsToDisplay, >- numberOfColumnsToDisplay); >- updateLeftRightUpDownButtonsForToolbar(); >+ refreshComposite(); > } > } > >@@ -615,9 +628,7 @@ > public void widgetSelected(SelectionEvent e) { > if (userY > 0) { > userY--; >- updateCompositeForNumberOfColumns(numberOfRowsToDisplay, >- numberOfColumnsToDisplay); >- updateLeftRightUpDownButtonsForToolbar(); >+ refreshComposite(); > } > } > >@@ -641,9 +652,7 @@ > public void widgetSelected(SelectionEvent e) { > if (!(userY + numberOfRowsToDisplay + 1 > getTotalNumberOfRows())) { > userY++; >- updateCompositeForNumberOfColumns(numberOfRowsToDisplay, >- numberOfColumnsToDisplay); >- updateLeftRightUpDownButtonsForToolbar(); >+ refreshComposite(); > } > } > >@@ -654,7 +663,75 @@ > widgetSelected(e); > } > }); >+ >+ new ToolItem(bar, SWT.SEPARATOR); >+ >+ ToolItem separator = new ToolItem(bar, SWT.SEPARATOR); >+ final Text textField = new Text(bar, SWT.SINGLE | SWT.BORDER); >+ textField.setText("XXXXX");//$NON-NLS-1$ >+ textField.setEnabled(true); >+ textField.pack(); >+ textField.setText(getDisplayScale(PrintHelperUtil.getScale())); >+ >+ separator.setWidth(textField.getBounds().width); >+ separator.setControl(textField); >+ >+ textField.addSelectionListener(new SelectionListener() { > >+ public void widgetSelected(SelectionEvent e) { >+ // do nothing. >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ String scaleFactor = ((Text) e.getSource()).getText(); >+ >+ int percentageIndex = scaleFactor.indexOf("%"); //$NON-NLS-1$ >+ if (percentageIndex > 0) { >+ scaleFactor = scaleFactor.substring(0, percentageIndex); >+ } >+ int scalePercentage = Integer.parseInt(scaleFactor); >+ setPercentScaling(scalePercentage); >+ refreshComposite(); >+ ((Text) e.getSource()).setText(getDisplayScale(scalePercentage)); >+ } >+ }); >+ >+ new ToolItem(bar, SWT.SEPARATOR); >+ >+ ToolItem fitToPageSeparator = new ToolItem(bar, SWT.SEPARATOR); >+ Button buttonFitToPage = new Button(bar, SWT.PUSH); >+ buttonFitToPage.setText(DiagramUIPrintingMessages.PrintPreview_FitToPage_ButtonText); >+ buttonFitToPage.setEnabled(true); >+ buttonFitToPage.pack(); >+ >+ fitToPageSeparator.setWidth(buttonFitToPage.getBounds().width); >+ fitToPageSeparator.setControl(buttonFitToPage); >+ >+ buttonFitToPage.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ >+ FitToPagesDialog fitToPages = new FitToPagesDialog(shell); >+ if (fitToPages.open() == Dialog.OK) { >+ int pagesWide = fitToPages.getPagesWide(); >+ int pagesTall = fitToPages.getPagesTall(); >+ PrintHelperUtil.setScaleToWidth(pagesWide); >+ PrintHelperUtil.setScaleToHeight(pagesTall); >+ >+ setFitToPage(pagesWide, pagesTall); >+ refreshComposite(); >+ textField.setText(getDisplayScale(PrintHelperUtil >+ .getScale())); >+ } >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // do nothing >+ } >+ }); >+ >+ >+ > new ToolItem(bar, SWT.SEPARATOR); > closeTool = new ToolItem(bar, SWT.NULL); > closeTool.setToolTipText(DiagramUIPrintingMessages.PrintPreview_CloseToolItem); >@@ -690,17 +767,16 @@ > > composite = new Composite(body, SWT.NULL); > composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); >- >- updateCompositeForNumberOfColumns(numberOfRowsToDisplay, numberOfColumnsToDisplay); >- >- updateLeftRightUpDownButtonsForToolbar(); >+ >+ refreshComposite(); > > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } >- >+ >+ dispose(); > shell.dispose(); > > } >@@ -926,6 +1002,17 @@ > } > > /** >+ * A convenience method for refreshing the displayed image in the preview. >+ */ >+ private void refreshComposite(){ >+ >+ updateCompositeForNumberOfColumns(numberOfRowsToDisplay, >+ numberOfColumnsToDisplay); >+ >+ updateLeftRightUpDownButtonsForToolbar(); >+ } >+ >+ /** > * Draw the composite centered on the body based on the number of columns. > * Also calls the method to make the images and insert them into the > * composite. >@@ -984,10 +1071,6 @@ > > PageMargins margins = PageInfoHelper.getPageMargins(getPreferenceStore(), getMapMode()); > >- margins.left /= userScale; >- margins.right /= userScale; >- margins.bottom /= userScale; >- margins.top /= userScale; > > //make sure height and width are not 0, if too small <4, don't bother > if (!(imageHeight <= 4 || imageWidth <= 4)) { >@@ -998,6 +1081,11 @@ > > scale *= userScale; > >+ margins.left /= userScale; >+ margins.right /= userScale; >+ margins.bottom /= userScale; >+ margins.top /= userScale; >+ > for (int i = 0; i < numberOfRows; i++) { > for (int j = 0; j < numberOfColumns; j++) { > Label label = new Label(composite, SWT.NULL); >@@ -1007,7 +1095,6 @@ > imageList.add(pageImg); > } > } >- > } > > composite.pack(); >@@ -1091,28 +1178,12 @@ > > //if mmg's font is null, gc.setFont will use a default font > gc.setFont(mmg.getFont()); >+ > drawPage(mmg, gc, scale, row, col, margins); >- >+ > gc.dispose(); > > return image; >- >- } >- >- /** >- * Convenience method to determine if a page at row y and >- * column x exists. >- * Pages start at 1. >- * >- * For example, the first page is 1-1. >- * >- * @param x, column number of the page to check >- * @param y, row number of the page to check >- * >- * @return boolean true if the page exists, false if it doesn't >- */ >- private boolean doesPageExist(int x, int y) { >- return x > 0 && y > 0 && x <= getTotalNumberOfColumns() && y <= getTotalNumberOfRows(); > } > > /** >@@ -1137,13 +1208,18 @@ > * displaying in the print preview. > */ > protected void drawPage(Graphics g, GC gc, float scale, int row, int col, PageMargins margins) { >+ > org.eclipse.draw2d.geometry.Point pageSize = PageInfoHelper >- .getPageSize(getPreferenceStore(), false, getMapMode()); >+ .getPageSize(getPreferenceStore(), false, getMapMode()); > > g.pushState(); >- >+ > Rectangle bounds = getBounds(); >- >+ >+ if (PrintHelperUtil.getScaleToWidth() == 1 && PrintHelperUtil.getScaleToHeight() == 1 && fitToPage) { >+ bounds = getDiagramEditPart().getChildrenBounds(); >+ } >+ > int scaledPageSizeWidth = (int)(pageSize.x/userScale) ; > int scaledPageSizeHeight = (int)(pageSize.y/userScale) ; > >@@ -1205,6 +1281,24 @@ > > g.popState(); > } >+ >+ >+ /** >+ * Convenience method to determine if a page at row y and >+ * column x exists. >+ * Pages start at 1. >+ * >+ * For example, the first page is 1-1. >+ * >+ * @param x, column number of the page to check >+ * @param y, row number of the page to check >+ * >+ * @return boolean true if the page exists, false if it doesn't >+ */ >+ private boolean doesPageExist(int x, int y) { >+ return x > 0 && y > 0 && x <= getTotalNumberOfColumns() && y <= getTotalNumberOfRows(); >+ } >+ > > /** > * Safely dispose an image >@@ -1271,9 +1365,372 @@ > ScaledGraphics scaledGraphics) { > return new MapModeGraphics(scaledGraphics, getMapMode()); > } >- >- public void setUserScale(double userScale){ >- this.userScale = userScale; >+ >+ /** >+ * Sets the scale factor. >+ * >+ * @param scale : valid input is an integer larger than 0 representing a scale percentage >+ */ >+ private void setUserScale(int scale){ >+ userScale = scale/100f; >+ PrintHelperUtil.setScale(scale); >+ } >+ >+ /** >+ * Prepare a string appropriate to show the scale factor to the user. >+ * >+ * @param scale the scale factor, an integer greater than 0. >+ * @return A string of the scale factor to be displayed to the user. >+ */ >+ private String getDisplayScale(int scale) { >+ return String.valueOf(scale) + "%"; //$NON-NLS-1$ > } >+ > >+ /** >+ * Determine the page count when fit to page is used. >+ * >+ * @param dgrmEP - The diagram edit part >+ * @param figureBounds - The bounds of the figure >+ * @param pageSize - Page size >+ * @param applyUserScale - The user scale >+ * @return Point.x contains the total number of pages that span in a column >+ * Point.y contains the total number of pages that span in a row >+ */ >+ protected org.eclipse.draw2d.geometry.Point getPageCount( >+ DiagramEditPart dgrmEP, Rectangle figureBounds, >+ org.eclipse.draw2d.geometry.Point pageSize, boolean applyUserScale) { >+ RootEditPart rootEditPart = dgrmEP.getRoot(); >+ >+ if (rootEditPart instanceof DiagramRootEditPart) { >+ >+ DiagramRootEditPart diagramRootEditPart = (DiagramRootEditPart) rootEditPart; >+ PageBreakEditPart pageBreakEditPart = diagramRootEditPart >+ .getPageBreakEditPart(); >+ >+ double fNumCols = ((PageBreaksFigure) pageBreakEditPart.getFigure()) >+ .getPageCount().y >+ * (applyUserScale ? userScale : 1); >+ >+ double fNumRows = ((PageBreaksFigure) pageBreakEditPart.getFigure()) >+ .getPageCount().x >+ * (applyUserScale ? userScale : 1); >+ >+ int numCols = (int) Math.ceil(fNumCols); >+ int numRows = (int) Math.ceil(fNumRows); >+ >+ return new org.eclipse.draw2d.geometry.Point(numCols, numRows); >+ >+ } else { >+ double fNumRows = (figureBounds.height * (applyUserScale ? userScale : 1)) >+ / pageSize.y; >+ int numRows = (int) Math.ceil(fNumRows); >+ >+ double fNumCols = (figureBounds.width * (applyUserScale ? userScale : 1)) >+ / pageSize.x; >+ int numCols = (int) Math.ceil(fNumCols); >+ >+ return new org.eclipse.draw2d.geometry.Point(numCols, numRows); >+ } >+ } >+ >+ /** >+ * Reset the fit to page flag and set the user scale when the >+ * preview is triggered from the print dialog. >+ * >+ * @param userScale a whole number greater than zero >+ */ >+ public void setPercentScaling(int userScale){ >+ fitToPage = false; >+ setUserScale(userScale); >+ } >+ >+ /** >+ * Recalculates a zoom ratio that can be used when displaying fit to page. >+ * >+ * @param rows The number of rows to fit the display to. >+ * @param columns The number of columns to fit the display to. >+ */ >+ public void setFitToPage(int width, int height) { >+ >+ fitToPage = true; >+ >+ initializeMapMode(); >+ >+ Rectangle figureBounds = PrintHelperUtil.getPageBreakBounds( >+ getDiagramEditPart(), true); >+ >+ org.eclipse.draw2d.geometry.Point pageBounds = PageInfoHelper >+ .getPageSize(getPreferenceStore(), getMapMode()); >+ org.eclipse.draw2d.geometry.Point pageCount = getPageCount( >+ getDiagramEditPart(), figureBounds, pageBounds, false); >+ int numCols = pageCount.x; >+ int numRows = pageCount.y; >+ >+ float actualWidth = 0; >+ float actualHeight = 0; >+ >+ if (height == 1 && width == 1) { >+ figureBounds = getDiagramEditPart().getChildrenBounds(); >+ actualWidth = figureBounds.width; >+ actualHeight = figureBounds.height; >+ } else { >+ actualWidth = numCols * pageBounds.x; >+ actualHeight = numRows * pageBounds.y; >+ } >+ >+ int totalHeight = (height * pageBounds.y); >+ int totalWidth = (width * pageBounds.x); >+ >+ int vScale = (int) ((totalHeight * 100) / actualHeight); >+ int hScale = (int) ((totalWidth * 100) / actualWidth); >+ >+ setUserScale(Math.min(hScale, vScale)); >+ } >+ >+ >+ /** >+ * A dialog that prompts the user for scaling the print settings >+ * to the number of pages wide and tall. >+ * Scale to Pages will affect zoom and offsets. It will maximize the >+ * scaling factor and modify offsets to fit the entire image within >+ * the pages specified. >+ * >+ * @author James Bruck (jbruck) >+ * >+ */ >+ private class FitToPagesDialog extends Dialog { >+ >+ /** >+ * The text field that holds the pages width >+ */ >+ private Text textWide; >+ /** >+ * The text field that holds the pages height >+ */ >+ private Text textTall; >+ /** >+ * The number of pages wide >+ */ >+ private int pagesWide = 0; >+ /** >+ * The number of pages tall >+ */ >+ private int pagesTall = 0; >+ >+ public FitToPagesDialog(Shell parent) { >+ super(parent); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) >+ */ >+ protected void configureShell(Shell newShell) { >+ super.configureShell(newShell); >+ >+ newShell.setText(DiagramUIPrintingMessages.PrintPreview_FitToPage_DialogTitle); >+ } >+ >+ /** >+ * A helper that creates a label. >+ * >+ * @param parent >+ * @param text >+ * @return a newly created label. >+ */ >+ Label label(Composite parent, String text) { >+ Label result = new Label(parent, SWT.NONE); >+ result.setText(text); >+ return result; >+ } >+ >+ /** >+ * A helper that gets layout data or creates >+ * it as necessary. >+ * >+ * @param control >+ * @return GridData for the layout >+ */ >+ GridData getLayoutData(Control control) { >+ GridData result = (GridData) control.getLayoutData(); >+ >+ if (result == null) { >+ result = new GridData(); >+ control.setLayoutData(result); >+ } >+ return result; >+ } >+ >+ /** >+ * A helper to layout items horizontally. >+ * >+ * @param control >+ * @param inset >+ * @return The layed out control >+ */ >+ Control layoutHorizontalIndent(Control control, int inset) { >+ GridData data = getLayoutData(control); >+ data.horizontalIndent = inset; >+ >+ return control; >+ } >+ >+ /** >+ * A helper to right justify a control. >+ * >+ * @param control >+ * @return The layed out control >+ */ >+ Control layoutAlignRight(Control control) { >+ GridData data = getLayoutData(control); >+ >+ data.horizontalAlignment = SWT.END; >+ data.grabExcessHorizontalSpace = false; >+ >+ return control; >+ } >+ >+ /** >+ * A helper to layout a certain number of dialog units wide. >+ * @param control >+ * @param dlus >+ * @return the aligned out control >+ */ >+ Control layoutWidth(Control control, int dlus) { >+ if (dlus > 0) { >+ GridData data = getLayoutData(control); >+ data.widthHint = convertHorizontalDLUsToPixels(dlus); >+ } >+ return control; >+ } >+ >+ /** >+ * A helper that lays out the given control horizontally. >+ * >+ * @param control >+ * @param grab >+ * @return The aligned control >+ */ >+ Control layoutFillHorizontal(Control control, boolean grab) { >+ GridData data = getLayoutData(control); >+ >+ data.horizontalAlignment = SWT.FILL; >+ data.grabExcessHorizontalSpace = grab; >+ >+ return control; >+ } >+ >+ /** >+ * A helper that creates a new text field. >+ * >+ * @param parent >+ * @param width >+ * @return a newly created text field >+ */ >+ Text text(Composite parent, int width) { >+ Text result = new Text(parent, SWT.SINGLE | SWT.BORDER); >+ layoutFillHorizontal(result, false); >+ layoutWidth(result, width); >+ >+ return result; >+ } >+ >+ /** >+ * A helper that lays out a control grabbing both horizontal and >+ * vertical extra spacing. >+ * >+ * @param control >+ * @return >+ */ >+ Control layoutFillBoth(Control control) { >+ GridData data = getLayoutData(control); >+ >+ data.horizontalAlignment = SWT.FILL; >+ data.grabExcessHorizontalSpace = true; >+ data.verticalAlignment = SWT.FILL; >+ data.grabExcessVerticalSpace = true; >+ >+ return control; >+ } >+ >+ /** >+ * A helper that creates a new group. >+ * >+ * @param parent >+ * @param text >+ * @return A newly created group. >+ */ >+ Group group(Composite parent, String text) { >+ Group result = new Group(parent, SWT.NONE); >+ result.setText(text); >+ layoutFillBoth(result); >+ return result; >+ } >+ >+ /** >+ * Layout the given control with the number of columns specified. >+ * >+ * @param composite >+ * @param columns >+ * @return The aligned out control >+ */ >+ Composite layout(Composite composite, int columns) { >+ GridLayout g = new GridLayout(columns, false); >+ g.marginLeft = 6; >+ g.marginRight = 6; >+ g.marginTop = 6; >+ g.marginBottom = 3; >+ composite.setLayout(g); >+ >+ return composite; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createDialogArea(Composite parent) { >+ >+ Composite composite = new Composite(parent, SWT.NONE); >+ layout(composite, 1); >+ Composite scaleGroup = group(composite, >+ DiagramUIPrintingMessages.JPSPrintDialog_Scaling); >+ layout(scaleGroup, 5); >+ >+ layoutHorizontalIndent(layoutAlignRight(label(scaleGroup, >+ DiagramUIPrintingMessages.JPSPrintDialog_PagesWide)), 15); >+ >+ textWide = text(scaleGroup, 20); >+ textWide.setText(String.valueOf(PrintHelperUtil.getScaleToWidth())); >+ >+ layoutHorizontalIndent(layoutAlignRight(label(scaleGroup, >+ DiagramUIPrintingMessages.JPSPrintDialog_PagesTall)), 15); >+ textTall = text(scaleGroup, 20); >+ textTall >+ .setText(String.valueOf(PrintHelperUtil.getScaleToHeight())); >+ >+ return composite; >+ } >+ >+ public int getPagesWide() { >+ return pagesWide; >+ } >+ >+ public int getPagesTall() { >+ return pagesTall; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#okPressed() >+ */ >+ @Override >+ protected void okPressed() { >+ pagesWide = Integer.parseInt(textWide.getText()); >+ pagesTall = Integer.parseInt(textTall.getText()); >+ super.okPressed(); >+ } >+ } >+ > } >\ No newline at end of file >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/util/DiagramPrinterUtil.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/util/DiagramPrinterUtil.java,v >retrieving revision 1.7 >diff -u -r1.7 DiagramPrinterUtil.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/util/DiagramPrinterUtil.java 7 Mar 2008 16:51:33 -0000 1.7 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/util/DiagramPrinterUtil.java 24 Apr 2008 14:00:53 -0000 >@@ -26,7 +26,6 @@ > * This class now delegates its functionality to helpers that isolate out the > * printing via SWT printing. > * >- * This class is subject to change/deprecation in phase 2 of the printing enhancements. > * > * @author wdiu, Wayne Diu > */ >Index: src/org/eclipse/gmf/runtime/diagram/ui/printing/actions/PrintPreviewAction.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui.printing/src/org/eclipse/gmf/runtime/diagram/ui/printing/actions/PrintPreviewAction.java,v >retrieving revision 1.7 >diff -u -r1.7 PrintPreviewAction.java >--- src/org/eclipse/gmf/runtime/diagram/ui/printing/actions/PrintPreviewAction.java 7 Mar 2008 16:51:36 -0000 1.7 >+++ src/org/eclipse/gmf/runtime/diagram/ui/printing/actions/PrintPreviewAction.java 24 Apr 2008 14:00:53 -0000 >@@ -11,7 +11,6 @@ > > package org.eclipse.gmf.runtime.diagram.ui.printing.actions; > >-import org.eclipse.core.runtime.Platform; > import org.eclipse.gmf.runtime.common.ui.action.actions.IPrintActionHelper; > import org.eclipse.gmf.runtime.diagram.ui.printing.internal.l10n.DiagramUIPrintingMessages; > import org.eclipse.gmf.runtime.diagram.ui.printing.internal.printpreview.PrintPreviewHelper;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ahunter.eclipse
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 227373
:
96280
| 97467