3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.io
;
13 import java
.text
.SimpleDateFormat
;
14 import java
.util
.Calendar
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.eclipse
.jface
.wizard
.WizardPage
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.events
.MouseAdapter
;
20 import org
.eclipse
.swt
.events
.MouseEvent
;
21 import org
.eclipse
.swt
.layout
.GridData
;
22 import org
.eclipse
.swt
.layout
.GridLayout
;
23 import org
.eclipse
.swt
.widgets
.Button
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.swt
.widgets
.DirectoryDialog
;
26 import org
.eclipse
.swt
.widgets
.Label
;
27 import org
.eclipse
.swt
.widgets
.Text
;
29 import eu
.etaxonomy
.taxeditor
.datasource
.CdmDataSourceRepository
;
36 public class JaxbExportDestinationWizardPage
extends WizardPage
{
38 public static final String DATE_FORMAT_NOW
= "yyyyMMdd-HHmm";
40 private static final Logger logger
= Logger
41 .getLogger(JaxbExportDestinationWizardPage
.class);
42 private DirectoryDialog folderDialog
;
43 private Text text_exportFileName
;
45 private Text text_folder
;
52 protected JaxbExportDestinationWizardPage(String pageName
) {
54 this.setTitle("JAXB Export");
56 this.setDescription("Exports the contents of the currently selected database into the cdm jaxb format.");
61 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
63 public void createControl(Composite parent
) {
65 setPageComplete(false);
67 Composite composite
= new Composite(parent
, SWT
.NONE
);
68 GridLayout gridLayout
= new GridLayout();
69 gridLayout
.numColumns
= 3;
70 composite
.setLayout(gridLayout
);
72 Label fileLabel
= new Label(composite
, SWT
.NONE
);
73 fileLabel
.setText("File");
75 text_exportFileName
= new Text(composite
, SWT
.BORDER
);
76 text_exportFileName
.setText(generateFilename());
77 text_exportFileName
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 2, 1));
80 Label folderLabel
= new Label(composite
, SWT
.NONE
);
81 folderLabel
.setText("Folder");
83 folderDialog
= new DirectoryDialog(parent
.getShell());
85 text_folder
= new Text(composite
, SWT
.BORDER
);
86 text_folder
.setEditable(false);
87 text_folder
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
90 Button button
= new Button(composite
, SWT
.PUSH
);
91 button
.setText("Browse...");
93 button
.addMouseListener(new MouseAdapter(){
96 * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
99 public void mouseUp(MouseEvent e
) {
100 String path
= folderDialog
.open();
101 text_folder
.setText(path
);
102 setPageComplete(true);
107 // make the composite the wizard pages control
108 setControl(composite
);
111 private String
generateFilename(){
112 StringBuffer buffer
= new StringBuffer();
113 buffer
.append("jaxb_export_");
114 buffer
.append(CdmDataSourceRepository
.getDefault().getCurrentDataSource());
117 Calendar cal
= Calendar
.getInstance();
118 SimpleDateFormat sdf
= new SimpleDateFormat(DATE_FORMAT_NOW
);
119 buffer
.append(sdf
.format(cal
.getTime()));
121 buffer
.append(".xml");
123 return buffer
.toString();
128 * @return the exportFileName
130 public Text
getExportFileName() {
131 return text_exportFileName
;
136 * @return the folderText
138 public Text
getFolderText() {