(GraphicFormat format)
| 1206 | } |
| 1207 | |
| 1208 | public final void doExportGraphic(GraphicFormat format) { |
| 1209 | FileDialog dialog = new FileDialog(this, |
| 1210 | "Export " + format.getName() + " File...", |
| 1211 | FileDialog.SAVE); |
| 1212 | |
| 1213 | String name = this.getFile().getName() + "." + format.getName().toLowerCase(); |
| 1214 | dialog.setFile(name); |
| 1215 | |
| 1216 | dialog.setVisible(true); |
| 1217 | if (dialog.getFile() != null) { |
| 1218 | File file = new File(dialog.getDirectory(), dialog.getFile()); |
| 1219 | |
| 1220 | try { |
| 1221 | OutputStream stream = new FileOutputStream(file); |
| 1222 | |
| 1223 | exportGraphics(format, treeViewer.getContentPane(), stream); |
| 1224 | |
| 1225 | stream.flush(); |
| 1226 | stream.close(); |
| 1227 | } catch(DocumentException de) { |
| 1228 | JOptionPane.showMessageDialog(this, "Error writing PDF file: " + de, |
| 1229 | "Export PDF Error", |
| 1230 | JOptionPane.ERROR_MESSAGE); |
| 1231 | } catch (IOException ioe) { |
| 1232 | JOptionPane.showMessageDialog(this, "Error writing tree file: " + ioe.getMessage(), |
| 1233 | "Export Error", |
| 1234 | JOptionPane.ERROR_MESSAGE); |
| 1235 | } |
| 1236 | |
| 1237 | } |
| 1238 | |
| 1239 | } |
| 1240 | |
| 1241 | public final static void exportGraphics(GraphicFormat format, JComponent comp, OutputStream stream) throws IOException, DocumentException { |
| 1242 | switch (format) { |
no test coverage detected