]> gerrit.simantics Code Review - simantics/platform.git/blob
0959ae9f854b9ba3aa900acc84143f8c26b1466a
[simantics/platform.git] /
1 package org.simantics.document.ui.wizard;
2
3 import java.io.File;
4
5 import org.eclipse.jface.wizard.IWizardPage;
6 import org.eclipse.jface.wizard.Wizard;
7 import org.simantics.db.Resource;
8 import org.simantics.document.FileDocumentUtil;
9
10 public abstract  class FileDocumentImportWizard extends Wizard{
11         
12         FileSelectionPage fileSelectionPage;
13         
14         public FileDocumentImportWizard(Resource lib) {
15                 setWindowTitle("Document File import");
16                 setNeedsProgressMonitor(false);
17         }
18         
19         public abstract Resource getLib();
20         
21         public abstract Resource getRel();
22         
23         @Override
24         public void addPage(IWizardPage page) {
25                 addPage(fileSelectionPage = new FileSelectionPage());
26         }
27         
28         @Override
29         public boolean performFinish() {
30                 final String fileName = fileSelectionPage.getFileName();
31                 if (fileName == null || fileName.length() == 0) 
32                         return false;
33                 File file = new File(fileName);
34                 if (!file.exists() || !file.canRead())
35                         return false;
36                 FileDocumentUtil.importFileAsync(fileName, getLib(), getRel());
37                 
38                 return true;
39         }
40         
41         
42
43 }