Changeset 681
Legend:
- Unmodified
- Added
- Removed
-
Jupe/plugin.xml
r661 r681 94 94 id="org.jupe.plugin.exportWizards" 95 95 name="Jupe"/> 96 <wizard 97 category="org.jupe.plugin.exportWizards" 98 class="org.jupe.plugin.wizards.exports.graphic.ExportGraphicWizard" 99 icon="icons/jupe_cube_16.png" 100 id="org.jupe.plugin.wizards.ExportGraphic" 101 name="Jupe Graphic Export"/> 96 102 </extension> 97 103 <extension -
Jupe/src/org/jupe/plugin/wizards/exports/graphic/ExportGraphicWizard.java
r669 r681 18 18 package org.jupe.plugin.wizards.exports.graphic; 19 19 20 import java.io.File; 21 import java.io.FileOutputStream; 20 22 import java.util.Iterator; 21 23 22 24 import org.eclipse.core.resources.IProject; 23 25 import org.eclipse.core.resources.IResource; 26 import org.eclipse.draw2d.IFigure; 27 import org.eclipse.draw2d.SWTGraphics; 28 import org.eclipse.draw2d.Viewport; 29 import org.eclipse.draw2d.geometry.Dimension; 30 import org.eclipse.gef.GraphicalViewer; 31 import org.eclipse.gef.editparts.AbstractGraphicalEditPart; 24 32 import org.eclipse.jdt.core.IJavaProject; 25 33 import org.eclipse.jface.viewers.IStructuredSelection; 26 34 import org.eclipse.jface.wizard.Wizard; 35 import org.eclipse.swt.graphics.GC; 36 import org.eclipse.swt.graphics.Image; 37 import org.eclipse.swt.graphics.ImageData; 38 import org.eclipse.swt.graphics.ImageLoader; 39 import org.eclipse.swt.widgets.Display; 27 40 import org.eclipse.ui.IExportWizard; 28 41 import org.eclipse.ui.IWorkbench; 42 import org.jupe.plugin.exceptions.JupeExceptionLogOnly; 43 import org.jupe.plugin.wizards.exports.xmi.ChooseJupeExpDestWizardPage; 44 import org.jupe.plugin.wizards.exports.xmi.ChooseJupeFilesWizardPage; 29 45 30 46 /** … … 42 58 .getString("ExportGraphicWizard.tle_wizard"); //$NON-NLS-1$ 43 59 60 61 // new 62 63 /** 64 * Wizard page to choose jupe files to be exported 65 */ 66 private ChooseJupeFilesWizardPage fPageJupeFiles = null; 67 68 /** 69 * wizard page to choose xmi export destination 70 */ 71 private ChooseJupeExpDestWizardPage fPageExportDestination = null; 72 73 // ends new 74 75 76 private ExportGraphicWizardPage fPageFormat = null; 77 78 44 79 /** 45 80 * project on which this wizard was called … … 51 86 */ 52 87 public ExportGraphicWizard() { 88 super(); 53 89 setWindowTitle(WINDOW_TITLE); 90 setNeedsProgressMonitor(true); 54 91 } 55 92 … … 71 108 public boolean performFinish() { 72 109 // TODO : #53 call of graphic export routine 110 111 112 final int exportFormat = fPageFormat.getFormat(); 113 114 // TODO: get viewer?? 115 GraphicalViewer viewer = null; 116 117 // TODO : get location where diagram should be exported 118 String location = ""; 119 120 121 export(viewer,location,exportFormat); 122 73 123 return true; 74 124 } … … 93 143 } 94 144 } 145 146 // neu 147 public void export(GraphicalViewer viewer, String location, int format) 148 { 149 try 150 { 151 IFigure figure = ((AbstractGraphicalEditPart) viewer.getRootEditPart()).getFigure(); 152 153 File file = new File(location); 154 if (file.exists()) 155 { 156 // if (!MessageDialog.openQuestion(modeler.getSite().getShell(), "Overwrite", 157 // "The file already exists. Do you really want to overwrite it ?")) 158 // { 159 // return; 160 // } 161 } 162 else 163 { 164 file.createNewFile(); 165 } 166 167 FileOutputStream fos = new FileOutputStream(file); 168 169 if (figure instanceof Viewport) 170 { 171 // Reinit the figure 172 ((Viewport) figure).setViewLocation(0, 0); 173 } 174 175 Dimension size = figure.getPreferredSize(); 176 Image image = new Image(Display.getDefault(), size.width, size.height); 177 GC gc = new GC(image); 178 SWTGraphics graphics = new SWTGraphics(gc); 179 figure.paint(graphics); 180 181 ImageLoader loader = new ImageLoader(); 182 loader.data = new ImageData[] {image.getImageData()}; 183 184 loader.save(fos, format); 185 // loader.save(os, format); 186 187 } 188 catch (Exception e) 189 { 190 new JupeExceptionLogOnly("An error occured during export. See the error log for more details."); 191 192 } 193 } 194 95 195 96 196 } -
Jupe/src/org/jupe/plugin/wizards/exports/graphic/ExportGraphicWizardPage.java
r669 r681 34 34 public class ExportGraphicWizardPage extends WizardPage { 35 35 36 private Button jpgOutput = null; 37 private Button pngOutput = null; 38 private Button pdfOutput = null; 39 36 40 private static final String PAGE_DESCRIPTION = Messages 37 41 .getString("ExportGraphicWizardPage.msg_page_description"); //$NON-NLS-1$ … … 84 88 // descrText.setEditable(false); 85 89 86 final ButtonjpgOutput = new Button(outputGroup, SWT.RADIO);90 jpgOutput = new Button(outputGroup, SWT.RADIO); 87 91 jpgOutput.setText("JPG"); //$NON-NLS-1$ 88 92 jpgOutput.setSelection(true); 89 93 90 final ButtonpngOutput = new Button(outputGroup, SWT.RADIO);94 pngOutput = new Button(outputGroup, SWT.RADIO); 91 95 pngOutput.setText("PNG"); //$NON-NLS-1$ 92 96 93 final ButtonpdfOutput = new Button(outputGroup, SWT.RADIO);97 pdfOutput = new Button(outputGroup, SWT.RADIO); 94 98 pdfOutput.setText("PDF"); //$NON-NLS-1$ 95 99 … … 102 106 } 103 107 108 public int getFormat(){ 109 if (jpgOutput.getSelection()) { 110 return 0; 111 } 112 if (pngOutput.getSelection()) { 113 return 1; 114 } 115 if (pdfOutput.getSelection()) { 116 return 2; 117 } 118 else{ 119 return -1; 120 } 121 } 122 104 123 } -
Jupe/src/org/jupe/plugin/wizards/exports/graphic/messages.properties
r669 r681 1 ExportGraphicWizard.tle_wizard=Ou put Format for Classdiagram1 ExportGraphicWizard.tle_wizard=Output Format for Classdiagram 2 2 ExportGraphicWizard.tle_page_name=Graphic Output 3 3 ExportGraphicWizardPage.msg_page_description=Select the output format to be used for the classdiagram export.
