Révision 23
SRC/src/fr/triangle/hyperalign/gui/io/Opener.java (revision 23) | ||
---|---|---|
10 | 10 |
import javax.swing.JLabel; |
11 | 11 |
import javax.swing.JOptionPane; |
12 | 12 |
|
13 |
import fr.triangle.hyperalign.gui.HMManager;
|
|
13 |
import fr.triangle.hyperalign.gui.HMController;
|
|
14 | 14 |
import fr.triangle.hyperalign.gui.Hypermachiavel; |
15 |
import fr.triangle.hyperalign.gui.config.CorpusConfigPane; |
|
15 | 16 |
import fr.triangle.hyperalign.gui.config.MetadataPane; |
16 | 17 |
import fr.triangle.hyperalign.io.output.ProjectWriter; |
17 | 18 |
import fr.triangle.hyperalign.kernel.HyperalignData; |
18 | 19 |
import fr.triangle.hyperalign.kernel.HyperalignSettings; |
19 | 20 |
import fr.triangle.hyperalign.kernel.annot.Metadata; |
20 |
import fr.triangle.hyperalign.kernel.bd.DatabaseManager; |
|
21 |
import fr.triangle.hyperalign.kernel.bd.AnnotationDatabaseManager;
|
|
21 | 22 |
import fr.triangle.hyperalign.kernel.corpus.ParallelCorpus; |
22 | 23 |
import fr.triangle.hyperalign.kernel.corpus.text.HyperalignText; |
24 |
import fr.triangle.hyperalign.kernel.dico.Dictionary; |
|
23 | 25 |
import fr.triangle.hyperalign.kernel.termino.Terminology; |
24 | 26 |
|
25 | 27 |
public class Opener implements Observer { |
26 | 28 |
|
27 |
private URL urlTermino;
|
|
29 |
private URL urlDico;
|
|
28 | 30 |
private URL urlProject; |
29 | 31 |
private String message; |
30 | 32 |
|
... | ... | |
32 | 34 |
private HyperalignSettings has; |
33 | 35 |
|
34 | 36 |
private boolean uploadedText = false; |
35 |
private HMManager manager;
|
|
37 |
private HMController manager;
|
|
36 | 38 |
private ResourceBundle res; |
37 | 39 |
|
38 |
public Opener(HMManager manager, String config, boolean displayDico, boolean dropAnnotTable){
|
|
40 |
public Opener(HMController manager, String config, boolean displayDico, boolean dropAnnotTable){
|
|
39 | 41 |
this.has = new HyperalignSettings(); |
40 | 42 |
this.manager = manager; |
41 | 43 |
this.parent = Hypermachiavel.getInstance(); |
... | ... | |
43 | 45 |
HyperalignData.getInstance().addObserver(this); |
44 | 46 |
|
45 | 47 |
if(config.equals(HyperalignData.NEW_TEXT)){ |
46 |
|
|
47 | 48 |
openText(); |
48 | 49 |
} else if(config.equals(HyperalignData.OPEN_PROJECT)){ |
49 | 50 |
openProjectDialog(displayDico, dropAnnotTable); |
50 |
}else if(config.equals(HyperalignData.OPEN_TERMINO)){ |
|
51 |
openTerminologyDialog(); |
|
52 |
}else if(config.equals(HyperalignData.SAVE_PROJECT)){ |
|
51 |
}else if(config.equals(HyperalignData.OPEN_DICO)){ |
|
52 |
openDictionaryDialog(); |
|
53 |
}else if(config.equals(HyperalignData.NEW_PROJECT)){ |
|
54 |
openNewProjectDialog(); |
|
55 |
} |
|
56 |
else if(config.equals(HyperalignData.SAVE_PROJECT)){ |
|
53 | 57 |
saveProject(); |
54 | 58 |
} |
55 | 59 |
} |
56 | 60 |
|
61 |
|
|
62 |
|
|
57 | 63 |
public String saveProject(){ |
58 | 64 |
String directory = manager.getDataManager().getProjectDirectory(); |
59 | 65 |
message = res.getString("I18N_OPENER_SAVE_MESSAGE_LABEL"); |
... | ... | |
61 | 67 |
message = Hypermachiavel.getInstance().chooseDirectory(); |
62 | 68 |
String name = manager.getDataManager().getProjectName()[1]; |
63 | 69 |
message = name+" "+message; |
64 |
directory = manager.getDataManager().getProjectDirectory();
|
|
70 |
directory = manager.getDataManager().getProjectName()[0];
|
|
65 | 71 |
ProjectWriter writer = new ProjectWriter(manager.getDataManager()); |
66 |
try {
|
|
67 |
writer.save(directory);
|
|
68 |
} catch (MalformedURLException e) {
|
|
69 |
// TODO Auto-generated catch block
|
|
70 |
e.printStackTrace();
|
|
71 |
}
|
|
72 |
writer.saveProject(directory, name);
|
|
73 |
}else {
|
|
74 |
String name = manager.getDataManager().getProjectName()[1];
|
|
75 |
directory = manager.getDataManager().getProjectName()[0];
|
|
76 |
ProjectWriter writer = new ProjectWriter(manager.getDataManager());
|
|
77 |
writer.saveProject(directory, name);
|
|
72 | 78 |
} |
73 | 79 |
return message; |
74 | 80 |
} |
... | ... | |
77 | 83 |
return message; |
78 | 84 |
} |
79 | 85 |
|
86 |
private void openNewProjectDialog(){ |
|
87 |
manager.getCorpusController().openCorpus(true);//true |
|
88 |
} |
|
89 |
|
|
80 | 90 |
private void openProjectDialog(boolean displayDico, boolean dropAnnotTable){ |
81 | 91 |
urlProject = manager.openFile("align"); |
82 | 92 |
if(urlProject!=null){ |
83 |
manager.getDataManager().setProjectDirectory(urlProject.getPath()); |
|
84 |
manager.openProject(urlProject, displayDico, dropAnnotTable); |
|
93 |
int indx = urlProject.getPath().lastIndexOf("/"); |
|
94 |
String nameProject = urlProject.getPath().substring(0, indx); |
|
95 |
|
|
96 |
manager.getDataManager().setProjectDirectory(nameProject/*urlProject.getPath()*/); |
|
97 |
manager.getCorpusController().openProject(urlProject, displayDico, dropAnnotTable); |
|
85 | 98 |
} |
86 | 99 |
} |
87 | 100 |
|
88 |
private void openTerminologyDialog(){
|
|
89 |
urlTermino = manager.openFile("tei");
|
|
90 |
if(urlTermino!=null){
|
|
91 |
JLabel message = new JLabel(res.getString("I18N_OPENER_LABEL_CHOOSETERMINO"));
|
|
92 |
Terminology [] terminos = manager.getDataManager().getTerminologyManager().getTerminologies();
|
|
93 |
JComboBox comboTermino = new JComboBox(terminos);
|
|
94 |
comboTermino.setSelectedIndex(0);
|
|
101 |
private void openDictionaryDialog(){
|
|
102 |
urlDico = manager.openFile("tei");
|
|
103 |
if(urlDico!=null){
|
|
104 |
JLabel message = new JLabel(res.getString("I18N_OPENER_LABEL_CHOOSEDICO"));
|
|
105 |
Dictionary [] dicos = manager.getDataManager().getDictionaryManager().getDictionaries();
|
|
106 |
JComboBox combo = new JComboBox(dicos);
|
|
107 |
combo.setSelectedIndex(0); |
|
95 | 108 |
|
96 |
Object[] params = {message, comboTermino};
|
|
97 |
int n = JOptionPane.showConfirmDialog(parent, params, res.getString("I18N_OPENER_TITLE_CHOOSETERMINO"), JOptionPane.YES_NO_OPTION);
|
|
98 |
Terminology selectedTerminology = (Terminology) comboTermino.getSelectedItem();
|
|
99 |
selectedTerminology.setUrl(urlTermino);
|
|
100 |
selectedTerminology.buildData(urlTermino);
|
|
109 |
Object[] params = {message, combo}; |
|
110 |
int n = JOptionPane.showConfirmDialog(parent, params, res.getString("I18N_OPENER_TITLE_CHOOSEDICO"), JOptionPane.YES_NO_OPTION);
|
|
111 |
Dictionary selectedDico = (Dictionary) combo.getSelectedItem();
|
|
112 |
selectedDico.setUrl(urlDico);
|
|
113 |
selectedDico.buildData(urlDico);
|
|
101 | 114 |
manager.reinitHyperalignPane(Hypermachiavel.INFORMATION_TAB, true, true);//0 |
102 | 115 |
} |
103 | 116 |
} |
... | ... | |
108 | 121 |
*/ |
109 | 122 |
private void openText(){ |
110 | 123 |
if(!uploadedText){ |
111 |
uploadedText = manager.setNameForText(); |
|
124 |
uploadedText = manager.getCorpusController().setNameForText();
|
|
112 | 125 |
} |
113 | 126 |
} |
114 | 127 |
|
Formats disponibles : Unified diff