Revision 43
SRC/src/fr/triangle/hyperalign/gui/config/CorpusConfigPane.java (revision 43) | ||
---|---|---|
12 | 12 |
import java.awt.event.MouseAdapter; |
13 | 13 |
import java.awt.event.MouseEvent; |
14 | 14 |
import java.awt.event.MouseListener; |
15 |
import java.awt.event.WindowAdapter; |
|
16 |
import java.awt.event.WindowEvent; |
|
17 |
import java.beans.PropertyChangeEvent; |
|
18 |
import java.beans.PropertyChangeListener; |
|
15 | 19 |
import java.io.File; |
20 |
import java.net.MalformedURLException; |
|
21 |
import java.net.URISyntaxException; |
|
16 | 22 |
import java.net.URL; |
17 | 23 |
import java.util.Collection; |
18 | 24 |
import java.util.HashMap; |
... | ... | |
29 | 35 |
import javax.swing.Icon; |
30 | 36 |
import javax.swing.ImageIcon; |
31 | 37 |
import javax.swing.JButton; |
38 |
import javax.swing.JCheckBox; |
|
32 | 39 |
import javax.swing.JComboBox; |
40 |
import javax.swing.JDialog; |
|
33 | 41 |
import javax.swing.JLabel; |
34 | 42 |
import javax.swing.JList; |
35 | 43 |
import javax.swing.JOptionPane; |
... | ... | |
39 | 47 |
import javax.swing.JTextField; |
40 | 48 |
import javax.swing.SwingConstants; |
41 | 49 |
|
42 |
|
|
43 |
import fr.triangle.hyperalign.gui.HMManager; |
|
50 |
import fr.triangle.hyperalign.gui.HMController; |
|
44 | 51 |
import fr.triangle.hyperalign.gui.Hypermachiavel; |
52 |
import fr.triangle.hyperalign.gui.io.Opener; |
|
45 | 53 |
import fr.triangle.hyperalign.kernel.FileManager; |
46 | 54 |
import fr.triangle.hyperalign.kernel.HyperalignData; |
55 |
import fr.triangle.hyperalign.kernel.TEITags; |
|
47 | 56 |
import fr.triangle.hyperalign.kernel.annot.Metadata; |
48 | 57 |
import fr.triangle.hyperalign.kernel.corpus.ParallelCorpus; |
49 | 58 |
import fr.triangle.hyperalign.kernel.corpus.ParallelCorpusParameters; |
50 | 59 |
import fr.triangle.hyperalign.kernel.corpus.text.HyperalignText; |
60 |
import fr.triangle.hyperalign.kernel.dico.Dictionary; |
|
51 | 61 |
import fr.triangle.hyperalign.kernel.termino.Terminology; |
62 |
import fr.triangle.hyperalign.kernel.util.FileOperation; |
|
52 | 63 |
import fr.triangle.hyperalign.kernel.util.ImageConfigure; |
53 | 64 |
|
54 |
public class CorpusConfigPane extends JPanel implements Observer, MouseListener, ActionListener {
|
|
65 |
public class CorpusConfigPane extends JDialog implements Observer, MouseListener, ActionListener, PropertyChangeListener {
|
|
55 | 66 |
|
56 | 67 |
private static final long serialVersionUID = 1L; |
57 | 68 |
private ResourceBundle res; |
58 | 69 |
private String iconPath = "fr/triangle/hyperalign/gui/icons"; |
70 |
private JPanel panel; |
|
71 |
private JOptionPane optionPane; |
|
72 |
private String enterText; |
|
73 |
private String cancelText; |
|
59 | 74 |
private boolean corpusModel = true; |
60 | 75 |
private URL urlCorpus; |
61 | 76 |
private String idPath = "TEI/teiHeader/fileDesc/sourceDesc/biblStruct/monogr/@xml:id"; |
... | ... | |
81 | 96 |
private URL selectedURL; |
82 | 97 |
private boolean taggedByTT = false; |
83 | 98 |
private String exportFormat = "TEI"; |
99 |
private String fileExt = "tei"; |
|
84 | 100 |
|
101 |
private JComboBox comboCreateDicoRes; |
|
102 |
private String createDicoRes = "yes"; |
|
85 | 103 |
//In case for creating a corpus (with txt files) |
86 | 104 |
private HashMap<HyperalignText, URL> textsToParallelize; |
87 |
private HMManager manager; |
|
88 | 105 |
|
106 |
private boolean projectBuilt = false; |
|
107 |
private HMController manager; |
|
89 | 108 |
|
90 |
public CorpusConfigPane(HMManager manager){
|
|
109 |
public CorpusConfigPane(HMController manager){
|
|
91 | 110 |
this.res = HyperalignData.getInstance().getResourceBundle(); |
92 | 111 |
HyperalignData.getInstance().addObserver(this); |
93 | 112 |
this.manager = manager; |
... | ... | |
98 | 117 |
|
99 | 118 |
|
100 | 119 |
public void initGui(boolean reinit){ |
120 |
this.setSize(600,400); |
|
121 |
this.setTitle(res.getString("I18N_CORPUSCONFIGPANE_BORDERTITLE_CORPUS")); |
|
122 |
enterText = res.getString("I18N_DIALOG_ENTER"); |
|
123 |
cancelText = res.getString("I18N_DIALOG_CANCEL"); |
|
101 | 124 |
//this.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_BORDERTITLE_CORPUS"))); |
102 | 125 |
if(reinit){ |
103 | 126 |
this.removeAll(); |
104 | 127 |
} |
128 |
panel = new JPanel(); |
|
129 |
panel.setLayout(new GridBagLayout()); |
|
105 | 130 |
|
106 |
if(manager.getInitParams(HMManager.NEWCORPUS_INIT)){ |
|
107 |
this.setLayout(new GridBagLayout()); |
|
108 |
JPanel mainPane = new JPanel(); |
|
109 |
mainPane.setLayout(new GridBagLayout()); |
|
131 |
if(manager.getInitParams(HMController.CORPUS_INIT)){ |
|
132 |
System.out.println("CorpusConfigPane : NEW Corpus"); |
|
110 | 133 |
// NEW CORPUS |
111 | 134 |
//-------TEXTS |
112 | 135 |
GridBagConstraints c = new GridBagConstraints(); |
... | ... | |
114 | 137 |
c.gridy =0; |
115 | 138 |
c.insets = new Insets(10,10,0,0); //top padding |
116 | 139 |
JPanel t = initTextsPane(); |
117 |
mainPane.add(t, c);
|
|
140 |
panel.add(t, c);
|
|
118 | 141 |
|
119 | 142 |
//-------FORMAT |
120 | 143 |
c = new GridBagConstraints(); |
... | ... | |
122 | 145 |
c.gridy =0; |
123 | 146 |
c.insets = new Insets(10,10,0,0); //top padding |
124 | 147 |
JPanel p = initCorpusModelPane(); |
125 |
mainPane.add(p, c); |
|
126 |
|
|
127 |
|
|
128 |
JPanel buttonPane = new JPanel(); |
|
129 |
JButton cancelButt = new JButton(res.getString("I18N_CORPUSCONFIGPANE_BUTTON_CANCEL")); |
|
130 |
cancelButt.addActionListener(new ActionListener(){ |
|
131 |
public void actionPerformed(ActionEvent ae){ |
|
132 |
clearAndHide(); |
|
133 |
} |
|
134 |
}); |
|
135 |
buttonPane.add(cancelButt); |
|
136 |
|
|
137 |
c = new GridBagConstraints(); |
|
138 |
c.gridx =0; |
|
139 |
c.gridy =0; |
|
140 |
this.add(mainPane, c); |
|
141 |
c = new GridBagConstraints(); |
|
142 |
c.gridx =0; |
|
143 |
c.gridy =1; |
|
144 |
this.add(buttonPane, c); |
|
145 |
}else if(manager.getInitParams(HMManager.CORPUS_INIT)){ |
|
146 |
this.setLayout(new GridBagLayout()); |
|
148 |
panel.add(p, c); |
|
149 |
}else { |
|
150 |
System.out.println("CorpusConfigPane : OPEN Corpus"); |
|
147 | 151 |
// OPEN CORPUS |
148 | 152 |
//-------MODEL |
149 | 153 |
JPanel m = initModelPane(); |
... | ... | |
151 | 155 |
c.gridx =0; |
152 | 156 |
c.gridy =0; |
153 | 157 |
c.insets = new Insets(10,10,0,0); |
154 |
this.add(m,c);
|
|
158 |
panel.add(m,c);
|
|
155 | 159 |
|
156 | 160 |
//-------TAGGER |
157 | 161 |
JPanel t = initTaggerPane(); |
... | ... | |
159 | 163 |
c.gridx =0; |
160 | 164 |
c.gridy =1; |
161 | 165 |
c.insets = new Insets(10,10,0,0); |
162 |
this.add(t,c);
|
|
166 |
panel.add(t,c);
|
|
163 | 167 |
|
164 | 168 |
//-------TEI PATHS |
165 | 169 |
JPanel p = initPathsPane(); |
... | ... | |
167 | 171 |
c.gridx =0; |
168 | 172 |
c.gridy =2; |
169 | 173 |
c.insets = new Insets(10,10,0,0); |
170 |
this.add(p,c);
|
|
174 |
panel.add(p,c);
|
|
171 | 175 |
|
176 |
JPanel createDicoResPanel = new JPanel(); |
|
177 |
createDicoResPanel.setLayout(new GridLayout(2,1)); |
|
178 |
JLabel createDicoResLabel = new JLabel("Create dictionary resources"); |
|
179 |
Vector<String> createDicosStr = new Vector<String>(); |
|
180 |
createDicosStr.add("yes"); |
|
181 |
createDicosStr.add("no"); |
|
182 |
comboCreateDicoRes = new JComboBox(createDicosStr); |
|
183 |
createDicoResPanel.add(createDicoResLabel); |
|
184 |
createDicoResPanel.add(comboCreateDicoRes); |
|
185 |
comboCreateDicoRes.addActionListener(new ActionListener(){ |
|
186 |
public void actionPerformed(ActionEvent ae){ |
|
187 |
Object o = ((JComboBox)ae.getSource()).getSelectedItem(); |
|
188 |
comboCreateDicoRes.setSelectedItem(o); |
|
189 |
createDicoRes = (String) o; |
|
190 |
} |
|
191 |
}); |
|
172 | 192 |
JPanel uploadButtPanel = new JPanel(); |
193 |
uploadButtPanel.setLayout(new GridLayout(3,1)); |
|
194 |
JPanel fileExtensionPanel = new JPanel(); |
|
195 |
JRadioButton buttFileTxt = new JRadioButton("txt"); |
|
196 |
JRadioButton buttFileTei = new JRadioButton("xml-tei"); |
|
197 |
buttFileTxt.setActionCommand("txt"); |
|
198 |
buttFileTei.setActionCommand("xml-tei"); |
|
199 |
buttFileTei.setSelected(true); |
|
200 |
//Group the radio buttons. |
|
201 |
ButtonGroup group = new ButtonGroup(); |
|
202 |
group.add(buttFileTxt); |
|
203 |
group.add(buttFileTei); |
|
204 |
buttFileTxt.addActionListener(this); |
|
205 |
buttFileTei.addActionListener(this); |
|
206 |
fileExtensionPanel.setLayout(new GridLayout(2,1)); |
|
207 |
fileExtensionPanel.add(buttFileTei); |
|
208 |
fileExtensionPanel.add(buttFileTxt); |
|
209 |
|
|
173 | 210 |
JButton uploadButton = new JButton(res.getString("I18N_CORPUSCONFIGPANE_CORPUSTODOWNLOAD")); |
174 | 211 |
uploadButton.addActionListener(new ActionListener(){ |
175 | 212 |
public void actionPerformed(ActionEvent e) { |
176 | 213 |
openCorpus(); |
177 | 214 |
} |
178 | 215 |
}); |
216 |
uploadButtPanel.add(createDicoResPanel); |
|
217 |
uploadButtPanel.add(fileExtensionPanel); |
|
179 | 218 |
uploadButtPanel.add(uploadButton); |
180 | 219 |
c = new GridBagConstraints(); |
181 | 220 |
c.gridx =0; |
182 | 221 |
c.gridy =3; |
183 | 222 |
c.insets = new Insets(10,10,0,0); |
184 |
this.add(uploadButtPanel,c);
|
|
223 |
panel.add(uploadButtPanel,c);
|
|
185 | 224 |
} |
186 | 225 |
|
187 | 226 |
|
188 | 227 |
if(reinit){ |
189 | 228 |
this.repaint(); |
190 | 229 |
this.validate(); |
230 |
}else { |
|
231 |
initDialog(); |
|
232 |
this.pack(); |
|
233 |
this.setVisible(true); |
|
191 | 234 |
} |
235 |
|
|
192 | 236 |
} |
193 | 237 |
|
238 |
private void initDialog(){ |
|
239 |
Object[] array = new Object[1]; |
|
240 |
array[0] = panel; |
|
241 |
|
|
242 |
//Create an array specifying the number of dialog buttons and their text. |
|
243 |
Object[] options = {enterText, cancelText}; |
|
244 |
|
|
245 |
//Create the JOptionPane. |
|
246 |
optionPane = new JOptionPane(array, |
|
247 |
JOptionPane.PLAIN_MESSAGE, |
|
248 |
JOptionPane.YES_NO_OPTION, |
|
249 |
null, |
|
250 |
options, |
|
251 |
options[0]); |
|
252 |
|
|
253 |
//Make this dialog display it. |
|
254 |
setContentPane(optionPane); |
|
255 |
|
|
256 |
//Handle window closing correctly. |
|
257 |
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); |
|
258 |
addWindowListener(new WindowAdapter() { |
|
259 |
public void windowClosing(WindowEvent we) { |
|
260 |
/* |
|
261 |
* Instead of directly closing the window, |
|
262 |
* we're going to change the JOptionPane's |
|
263 |
* value property. |
|
264 |
*/ |
|
265 |
optionPane.setValue(new Integer(JOptionPane.CLOSED_OPTION)); |
|
266 |
} |
|
267 |
}); |
|
268 |
|
|
269 |
//Register an event handler that reacts to option pane state changes. |
|
270 |
optionPane.addPropertyChangeListener(this); |
|
271 |
} |
|
272 |
|
|
194 | 273 |
private JPanel initPathsPane(){ |
195 | 274 |
JPanel pathsPanel = new JPanel(new GridLayout(6,2)); |
196 |
pathsPanel.setPreferredSize(new Dimension(600,120)); |
|
275 |
//pathsPanel.setPreferredSize(new Dimension(600,120));
|
|
197 | 276 |
pathsPanel.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_LABEL_CONFIGTEIPATH"))); |
198 | 277 |
|
199 | 278 |
JLabel author = new JLabel(res.getString("I18N_CORPUSCONFIGPANE_LABEL_CONFIGTEIPATH_TEXTID")); |
200 | 279 |
authorField = new JTextField(idPath); |
201 | 280 |
pathsPanel.add(author); |
281 |
author.setPreferredSize(new Dimension (600,20)); |
|
282 |
authorField.setPreferredSize(new Dimension (600,20)); |
|
202 | 283 |
pathsPanel.add(authorField); |
203 | 284 |
|
204 | 285 |
JLabel lang = new JLabel(res.getString("I18N_CORPUSCONFIGPANE_LABEL_CONFIGTEIPATH_LANG")); |
205 | 286 |
langField = new JTextField(languagePath); |
206 | 287 |
pathsPanel.add(lang); |
288 |
lang.setPreferredSize(new Dimension (600,20)); |
|
289 |
langField.setPreferredSize(new Dimension (600,20)); |
|
207 | 290 |
pathsPanel.add(langField); |
208 | 291 |
|
209 | 292 |
JLabel text = new JLabel(res.getString("I18N_CORPUSCONFIGPANE_LABEL_CONFIGTEIPATH_TEXT")); |
210 | 293 |
textField = new JTextField(textPath); |
211 | 294 |
pathsPanel.add(text); |
295 |
text.setPreferredSize(new Dimension (600,20)); |
|
296 |
textField.setPreferredSize(new Dimension (600,20)); |
|
212 | 297 |
pathsPanel.add(textField); |
213 | 298 |
return pathsPanel; |
214 | 299 |
} |
... | ... | |
267 | 352 |
|
268 | 353 |
private JPanel initTextsPane() { |
269 | 354 |
JPanel p = new JPanel(); |
355 |
p.setPreferredSize(new Dimension(300,300)); |
|
356 |
|
|
357 |
p.setLayout(new GridLayout(1,2)); |
|
358 |
|
|
270 | 359 |
//LEFT : list of texts (forming the parallel corpus) |
271 | 360 |
JPanel p1 = new JPanel(); |
272 |
if(manager.getInitParams(HMManager.NEWCORPUS_INIT)){ |
|
273 |
p1.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_BORDERTITLE_TEXTINCORPUSTOALIGN"))); |
|
274 |
|
|
275 |
}else { |
|
276 |
p1.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_BORDERTITLE_TEXTINCORPUS"))); |
|
277 |
|
|
278 |
} |
|
279 | 361 |
p1.setLayout(new GridBagLayout()); |
280 | 362 |
GridBagConstraints c = new GridBagConstraints(); |
281 | 363 |
c.gridx =0; |
... | ... | |
283 | 365 |
c.insets = new Insets(10,10,0,0); //top padding |
284 | 366 |
|
285 | 367 |
listTextsModel = new DefaultListModel(); |
286 |
if(!manager.getInitParams(HMManager.NEWCORPUS_INIT)){
|
|
368 |
if(!manager.getInitParams(HMController.NEWCORPUS_INIT)){
|
|
287 | 369 |
ParallelCorpus corpus = manager.getDataManager().getCorpusManager().getCorpus(); |
288 | 370 |
if(corpus.getUrl()!=null){ |
289 | 371 |
Collection<HyperalignText> texts = corpus.getParallelTexts().values(); |
... | ... | |
312 | 394 |
} |
313 | 395 |
}); |
314 | 396 |
scrollPaneTexts = new JScrollPane(listTexts); |
315 |
scrollPaneTexts.setPreferredSize(new Dimension(150,70)); |
|
316 |
|
|
397 |
scrollPaneTexts.setPreferredSize(new Dimension(150,100)); |
|
317 | 398 |
JPanel textPanel = new JPanel(); |
399 |
if(manager.getInitParams(HMController.NEWCORPUS_INIT)){ |
|
400 |
textPanel.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_BORDERTITLE_TEXTINCORPUSTOALIGN"))); |
|
401 |
|
|
402 |
}else { |
|
403 |
textPanel.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_BORDERTITLE_TEXTINCORPUS"))); |
|
404 |
|
|
405 |
} |
|
318 | 406 |
textPanel.add(scrollPaneTexts); |
319 | 407 |
p1.add(textPanel,c); |
320 | 408 |
|
... | ... | |
325 | 413 |
c.gridx =0; |
326 | 414 |
c.gridy =1; |
327 | 415 |
c.insets = new Insets(10,10,0,0); //top padding |
416 |
|
|
328 | 417 |
p1.add(buttP, c); |
329 | 418 |
|
330 | 419 |
|
... | ... | |
340 | 429 |
} |
341 | 430 |
} |
342 | 431 |
}); |
432 |
|
|
343 | 433 |
|
344 | 434 |
c = new GridBagConstraints(); |
345 | 435 |
c.gridx =0; |
... | ... | |
347 | 437 |
p1.add(metadataButton, c); |
348 | 438 |
p.add(p1); |
349 | 439 |
|
440 |
|
|
441 |
|
|
442 |
//p.add(p2); |
|
443 |
|
|
350 | 444 |
return p; |
351 | 445 |
} |
352 | 446 |
|
... | ... | |
395 | 489 |
//addText = false; |
396 | 490 |
selectedTextMetadata = null; |
397 | 491 |
} |
398 |
|
|
399 | 492 |
initGui(true); |
400 | 493 |
} |
401 | 494 |
|
... | ... | |
426 | 519 |
} |
427 | 520 |
|
428 | 521 |
private void openCorpus(){ |
429 |
urlCorpus = manager.openFile("tei");
|
|
522 |
urlCorpus = manager.openFile(fileExt);
|
|
430 | 523 |
idPath = authorField.getText(); |
431 | 524 |
languagePath = langField.getText(); |
432 | 525 |
textPath = textField.getText(); |
433 | 526 |
if(urlCorpus!=null){ |
434 |
manager.setCorpusData(urlCorpus, true, true, corpusModel, taggedByTT, idPath, languagePath, textPath); |
|
435 |
manager.setData(true); |
|
436 |
manager.saveProject(); |
|
527 |
|
|
528 |
String s = (String) JOptionPane.showInputDialog(this, res.getString("I18N_CORPUSCONFIGPANE_CHOOSEPROJECTNAME"), |
|
529 |
res.getString("I18N_CORPUSCONFIGPANE_CHOOSEPROJECTNAME_TITLE"), JOptionPane.QUESTION_MESSAGE); |
|
530 |
|
|
531 |
if((s != null) && (s.length() > 0)){ |
|
532 |
int indx = urlCorpus.getPath().lastIndexOf("/"); |
|
533 |
String fileDirectory = urlCorpus.getPath().substring(0,indx); |
|
534 |
File fileDir = new File(fileDirectory+"/"+s); |
|
535 |
boolean success = (fileDir).mkdirs(); |
|
536 |
System.out.println("CorpusConfigPane : directory = "+fileDir.getPath()); |
|
537 |
if (!success) { |
|
538 |
// Directory creation failed |
|
539 |
}else { |
|
540 |
manager.getDataManager().setProjectDirectory(fileDir.getPath()); |
|
541 |
try { |
|
542 |
//Copy corpus file (xml) in another file with correct naming |
|
543 |
//Will have to modify this code to implement when corpus is a text file, and change the manager.setCorpusData() below !! |
|
544 |
|
|
545 |
///////// WARNING VERSION before 2015-01-21 /////// |
|
546 |
//FileOperation.copy(new File(urlCorpus.toURI()), new File(fileDirectory+"/"+s+"/"+s+"_ParallelCorpus.xml")); |
|
547 |
//File newCorpus = new File(fileDirectory+"/"+s+"/"+s+"_ParallelCorpus.xml"); |
|
548 |
////////////////////////////////////////////////// |
|
549 |
|
|
550 |
///////// WARNING VERSION before 2017-03-10 /////// |
|
551 |
FileOperation.copy(new File(urlCorpus.toURI()), new File(fileDirectory+"/"+s+"/"+"ParallelCorpus.xml")); |
|
552 |
File newCorpus = new File(fileDirectory+"/"+s+"/"+"ParallelCorpus.xml"); |
|
553 |
|
|
554 |
urlCorpus = newCorpus.toURI().toURL(); |
|
555 |
} catch (URISyntaxException e) { |
|
556 |
// TODO Auto-generated catch block |
|
557 |
e.printStackTrace(); |
|
558 |
} catch (MalformedURLException e) { |
|
559 |
// TODO Auto-generated catch block |
|
560 |
e.printStackTrace(); |
|
561 |
} |
|
562 |
System.out.println("CorpusConfigPane : (a) project DIR : "+manager.getDataManager().getProjectName()[0]+" / (b) NAME : "+manager.getDataManager().getProjectName()[1]); |
|
563 |
} |
|
564 |
manager.getCorpusController().setCorpusData(urlCorpus, true, true, corpusModel, taggedByTT, idPath, languagePath, textPath); |
|
565 |
|
|
566 |
if(createDicoRes.equals("no")){ |
|
567 |
Opener opener = new Opener(manager, HyperalignData.OPEN_DICO, false, false); |
|
568 |
}else { |
|
569 |
Dictionary[] dicos = manager.getDataManager().getDictionaryManager().getDictionaries(); |
|
570 |
for(Dictionary dico : dicos){ |
|
571 |
File newDico = new File(fileDirectory+"/"+s+"/"+"Dictionary_"+dico.getName()+".xml"); |
|
572 |
URL urlDico; |
|
573 |
try { |
|
574 |
urlDico = newDico.toURI().toURL(); |
|
575 |
dico.setUrl(urlDico); |
|
576 |
System.out.println("CorpusConfigPane : URL dico = "+dico.getUrl().toString()); |
|
577 |
} catch (MalformedURLException e) { |
|
578 |
// TODO Auto-generated catch block |
|
579 |
e.printStackTrace(); |
|
580 |
} |
|
581 |
|
|
582 |
} |
|
583 |
} |
|
584 |
manager.getCorpusController().saveProject(); |
|
585 |
manager.getCorpusController().setData(true); |
|
586 |
projectBuilt = true; |
|
587 |
}else{ |
|
588 |
System.out.println("CorpusConfigPane : ERROR !"); |
|
589 |
} |
|
437 | 590 |
} |
438 | 591 |
} |
439 | 592 |
|
440 | 593 |
private void createCorpus(){ |
594 |
URL urlCorpus = manager.openFile("tei"); |
|
441 | 595 |
|
442 |
//////////////////// VOIR SI ON PEUT L'UTILISER |
|
443 |
//metadata.getMetadata(name);//LANG |
|
444 |
//String[] projectFileName = dataManager.getProjectName(); |
|
445 |
//String fileName = projectFileName[1]+"_"+"Dictionary_"+dictionary.getName()+".xml"; |
|
446 |
//File file = new File(projectFileName[0], fileName); |
|
447 |
//////////////////// |
|
448 |
|
|
449 | 596 |
openTaggerOption(); |
450 | 597 |
|
451 | 598 |
//BUILD CORPUS |
452 |
manager.setCorpusData(urlCorpus, true, true, corpusModel, taggedByTT, textsToParallelize); |
|
599 |
manager.getCorpusController().setCorpusData(urlCorpus, true, true, corpusModel, taggedByTT, textsToParallelize);
|
|
453 | 600 |
ParallelCorpus corpus = manager.getDataManager().getCorpusManager().getCorpus(); |
454 | 601 |
|
455 | 602 |
Metadata metadata = manager.getDataManager().createMetadata(corpus); |
... | ... | |
458 | 605 |
metadataPane.setLocation(300, 300); |
459 | 606 |
|
460 | 607 |
//SET GUI ELEMENTS with DATA |
461 |
manager.setData(false); |
|
608 |
manager.getCorpusController().setData(false);
|
|
462 | 609 |
|
463 | 610 |
//EXPORT |
464 | 611 |
Set<HyperalignText> keys = textsToParallelize.keySet(); |
... | ... | |
516 | 663 |
JPanel p = new JPanel(new GridBagLayout()); |
517 | 664 |
p.setBorder(BorderFactory.createTitledBorder(res.getString("I18N_CORPUSCONFIGPANE_EXPORTFORMAT"))); |
518 | 665 |
|
519 |
if(manager.getInitParams(HMManager.NEWCORPUS_INIT)){ |
|
520 |
JPanel projectPane = new JPanel(); |
|
521 |
JButton urlButt = new JButton("Choisir un fichier pour le corpus"); |
|
522 |
urlButt.addMouseListener(new MouseAdapter() { |
|
523 |
public void mouseClicked(MouseEvent e) { |
|
524 |
urlCorpus = manager.openFile("xml"); |
|
525 |
String path = urlCorpus.getPath(); |
|
526 |
int indx = path.lastIndexOf("/"); |
|
527 |
String fileDirectory = path.substring(0,indx); |
|
528 |
//String nameProjectFile = path.substring(indx+1, path.length()); |
|
529 |
manager.getDataManager().setProjectDirectory(fileDirectory); |
|
530 |
} |
|
531 |
}); |
|
532 |
projectPane.add(urlButt); |
|
533 |
GridBagConstraints c = new GridBagConstraints(); |
|
534 |
c.gridx = 0; |
|
535 |
c.gridy = 0; |
|
536 |
p.add(projectPane,c); |
|
537 |
|
|
538 |
|
|
666 |
if(manager.getInitParams(HMController.NEWCORPUS_INIT)){ |
|
539 | 667 |
//MUST CHOOSE WHICH TEI MODEL to use for storage and alignment |
540 | 668 |
JPanel buttonP = new JPanel(); |
541 | 669 |
buttonP.setLayout(new GridLayout(3,1)); |
... | ... | |
569 | 697 |
buttonP.add(b); |
570 | 698 |
buttonP.add(b2); |
571 | 699 |
buttonP.add(b3); |
572 |
|
|
573 |
c = new GridBagConstraints(); |
|
700 |
GridBagConstraints c = new GridBagConstraints(); |
|
574 | 701 |
c.gridx = 0; |
575 |
c.gridy = 1;
|
|
702 |
c.gridy = 0;
|
|
576 | 703 |
p.add(buttonP,c); |
577 | 704 |
|
578 | 705 |
if(exportFormat.equals("TMX") && !corpusModel){ |
... | ... | |
614 | 741 |
|
615 | 742 |
c = new GridBagConstraints(); |
616 | 743 |
c.gridx = 0; |
617 |
c.gridy = 2;
|
|
744 |
c.gridy = 1;
|
|
618 | 745 |
p.add(tmxTextsChoicePanel,c); |
619 | 746 |
} |
620 | 747 |
|
... | ... | |
634 | 761 |
|
635 | 762 |
//CREATE CORPUS |
636 | 763 |
JPanel buttPanel = new JPanel(); |
637 |
if(manager.getInitParams(HMManager.NEWCORPUS_INIT)){
|
|
764 |
if(manager.getInitParams(HMController.NEWCORPUS_INIT)){
|
|
638 | 765 |
JButton createCorpusButt = new JButton(res.getString("I18N_CORPUSCONFIGPANE_BUTTON_CREATECORPUS")); |
639 | 766 |
createCorpusButt.setToolTipText(res.getString("I18N_CORPUSCONFIGPANE_BUTTON_CREATECORPUS_TOOLTIP")); |
640 | 767 |
createCorpusButt.addActionListener(new ActionListener(){ |
... | ... | |
661 | 788 |
}); |
662 | 789 |
buttPanel.add(seeCorpusMetadata); |
663 | 790 |
} |
664 |
|
|
665 |
|
|
666 | 791 |
corpusModelPanel.add(buttPanel); |
667 | 792 |
|
668 | 793 |
return corpusModelPanel; |
669 | 794 |
} |
670 | 795 |
|
796 |
/** This method reacts to state changes in the option pane. */ |
|
797 |
public void propertyChange(PropertyChangeEvent e) { |
|
798 |
String prop = e.getPropertyName(); |
|
799 |
if (isVisible() |
|
800 |
&& (e.getSource() == optionPane) |
|
801 |
&& (JOptionPane.VALUE_PROPERTY.equals(prop) || |
|
802 |
JOptionPane.INPUT_VALUE_PROPERTY.equals(prop))) { |
|
803 |
Object value = optionPane.getValue(); |
|
804 |
|
|
805 |
if (value == JOptionPane.UNINITIALIZED_VALUE) { |
|
806 |
//ignore reset |
|
807 |
return; |
|
808 |
} |
|
809 |
|
|
810 |
optionPane.setValue(JOptionPane.UNINITIALIZED_VALUE); |
|
811 |
|
|
812 |
if (enterText.equals(value)) { |
|
813 |
if (projectBuilt) { |
|
814 |
clearAndHide(); |
|
815 |
}else |
|
816 |
{ |
|
817 |
JOptionPane.showMessageDialog(this, "Le projet n'a pas ?t? configur?, veuillez compl?ter le formulaire !"); |
|
818 |
} |
|
819 |
} |
|
820 |
if (cancelText.equals(value)) { |
|
821 |
clearAndHide(); |
|
822 |
} |
|
823 |
} |
|
824 |
} |
|
825 |
|
|
671 | 826 |
/** This method clears the dialog and hides it. */ |
672 | 827 |
public void clearAndHide() { |
828 |
System.out.println("CLEAR AND HIDE"); |
|
673 | 829 |
//Action avant de fermer !! |
674 | 830 |
removeAll(); |
675 | 831 |
JLabel label = new JLabel(res.getString("I18N_CORPUSCONFIGPANE_INFO_LABEL")); |
... | ... | |
754 | 910 |
|
755 | 911 |
if(e.getActionCommand().equals("TreeTagger")){ |
756 | 912 |
taggedByTT = true; |
913 |
//Give the location of TreeTagger |
|
757 | 914 |
System.out.println("------------ is to be TAGGED BY TREE TAGGER ! --------------"); |
758 | 915 |
} |
759 | 916 |
if(e.getActionCommand().equals("HyperalignTagger")){ |
... | ... | |
768 | 925 |
if(e.getActionCommand().equals("textremove")){ |
769 | 926 |
//removeText(); |
770 | 927 |
} |
928 |
|
|
929 |
if(e.getActionCommand().equals("txt")){ |
|
930 |
fileExt = "texte"; |
|
931 |
} |
|
932 |
if(e.getActionCommand().equals("tei")){ |
|
933 |
fileExt = "tei"; |
|
934 |
} |
|
771 | 935 |
|
772 | 936 |
|
773 | 937 |
} |
Also available in: Unified diff