Changeset 681

Show
Ignore:
Timestamp:
12/03/06 16:36:24 (4 years ago)
Author:
steffen
Message:

began work on export to jpg, gif, pdf, etc.
wizard can now be started

Location:
Jupe
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • Jupe/plugin.xml

    r661 r681  
    9494            id="org.jupe.plugin.exportWizards" 
    9595            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"/> 
    96102   </extension> 
    97103 <extension 
  • Jupe/src/org/jupe/plugin/wizards/exports/graphic/ExportGraphicWizard.java

    r669 r681  
    1818package org.jupe.plugin.wizards.exports.graphic; 
    1919 
     20import java.io.File; 
     21import java.io.FileOutputStream; 
    2022import java.util.Iterator; 
    2123 
    2224import org.eclipse.core.resources.IProject; 
    2325import org.eclipse.core.resources.IResource; 
     26import org.eclipse.draw2d.IFigure; 
     27import org.eclipse.draw2d.SWTGraphics; 
     28import org.eclipse.draw2d.Viewport; 
     29import org.eclipse.draw2d.geometry.Dimension; 
     30import org.eclipse.gef.GraphicalViewer; 
     31import org.eclipse.gef.editparts.AbstractGraphicalEditPart; 
    2432import org.eclipse.jdt.core.IJavaProject; 
    2533import org.eclipse.jface.viewers.IStructuredSelection; 
    2634import org.eclipse.jface.wizard.Wizard; 
     35import org.eclipse.swt.graphics.GC; 
     36import org.eclipse.swt.graphics.Image; 
     37import org.eclipse.swt.graphics.ImageData; 
     38import org.eclipse.swt.graphics.ImageLoader; 
     39import org.eclipse.swt.widgets.Display; 
    2740import org.eclipse.ui.IExportWizard; 
    2841import org.eclipse.ui.IWorkbench; 
     42import org.jupe.plugin.exceptions.JupeExceptionLogOnly; 
     43import org.jupe.plugin.wizards.exports.xmi.ChooseJupeExpDestWizardPage; 
     44import org.jupe.plugin.wizards.exports.xmi.ChooseJupeFilesWizardPage; 
    2945 
    3046/** 
     
    4258                        .getString("ExportGraphicWizard.tle_wizard"); //$NON-NLS-1$ 
    4359 
     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         
    4479        /** 
    4580         * project on which this wizard was called 
     
    5186         */ 
    5287        public ExportGraphicWizard() { 
     88                super(); 
    5389                setWindowTitle(WINDOW_TITLE); 
     90                setNeedsProgressMonitor(true); 
    5491        } 
    5592 
     
    71108        public boolean performFinish() { 
    72109                // 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                 
    73123                return true; 
    74124        } 
     
    93143                } 
    94144        } 
     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 
    95195 
    96196} 
  • Jupe/src/org/jupe/plugin/wizards/exports/graphic/ExportGraphicWizardPage.java

    r669 r681  
    3434public class ExportGraphicWizardPage extends WizardPage { 
    3535 
     36        private Button jpgOutput = null; 
     37        private Button pngOutput = null; 
     38        private Button pdfOutput = null; 
     39         
    3640        private static final String PAGE_DESCRIPTION = Messages 
    3741                        .getString("ExportGraphicWizardPage.msg_page_description"); //$NON-NLS-1$ 
     
    8488                // descrText.setEditable(false); 
    8589 
    86                 final Button jpgOutput = new Button(outputGroup, SWT.RADIO); 
     90                jpgOutput = new Button(outputGroup, SWT.RADIO); 
    8791                jpgOutput.setText("JPG"); //$NON-NLS-1$ 
    8892                jpgOutput.setSelection(true); 
    8993 
    90                 final Button pngOutput = new Button(outputGroup, SWT.RADIO); 
     94                pngOutput = new Button(outputGroup, SWT.RADIO); 
    9195                pngOutput.setText("PNG"); //$NON-NLS-1$ 
    9296 
    93                 final Button pdfOutput = new Button(outputGroup, SWT.RADIO); 
     97                pdfOutput = new Button(outputGroup, SWT.RADIO); 
    9498                pdfOutput.setText("PDF"); //$NON-NLS-1$ 
    9599 
     
    102106        } 
    103107 
     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         
    104123} 
  • Jupe/src/org/jupe/plugin/wizards/exports/graphic/messages.properties

    r669 r681  
    1 ExportGraphicWizard.tle_wizard=Ouput Format for Classdiagram 
     1ExportGraphicWizard.tle_wizard=Output Format for Classdiagram 
    22ExportGraphicWizard.tle_page_name=Graphic Output 
    33ExportGraphicWizardPage.msg_page_description=Select the output format to be used for the classdiagram export.