svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / gui / projectpanel / ProjectDocumentsPanelPage.java @ 47533
History | View | Annotate | Download (22 KB)
1 |
package org.gvsig.app.project.documents.gui.projectpanel; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Component; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.FlowLayout; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.ComponentAdapter; |
10 |
import java.awt.event.ComponentEvent; |
11 |
import java.awt.event.MouseAdapter; |
12 |
import java.awt.event.MouseEvent; |
13 |
import java.beans.PropertyChangeEvent; |
14 |
import java.beans.PropertyChangeListener; |
15 |
import java.beans.PropertyVetoException; |
16 |
import java.io.File; |
17 |
import java.util.Collections; |
18 |
import java.util.Comparator; |
19 |
import java.util.Iterator; |
20 |
import java.util.List; |
21 |
import javax.swing.ButtonGroup; |
22 |
import javax.swing.DefaultListCellRenderer; |
23 |
import javax.swing.JComponent; |
24 |
import javax.swing.JLabel; |
25 |
import javax.swing.JList; |
26 |
import javax.swing.JOptionPane; |
27 |
import javax.swing.JPanel; |
28 |
import javax.swing.JRadioButton; |
29 |
import javax.swing.JScrollPane; |
30 |
import javax.swing.ScrollPaneConstants; |
31 |
import javax.swing.SwingUtilities; |
32 |
import javax.swing.event.ListSelectionEvent; |
33 |
import javax.swing.event.ListSelectionListener; |
34 |
import org.apache.commons.lang3.ArrayUtils; |
35 |
import org.apache.commons.lang3.StringUtils; |
36 |
import org.gvsig.andami.IconThemeHelper; |
37 |
import org.gvsig.andami.PluginServices; |
38 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
39 |
import org.gvsig.andami.ui.mdiManager.MDIManager; |
40 |
import org.gvsig.app.ApplicationLocator; |
41 |
import org.gvsig.app.ApplicationManager; |
42 |
import org.gvsig.app.project.Project; |
43 |
import org.gvsig.app.project.ProjectManager; |
44 |
import org.gvsig.app.project.documents.Document; |
45 |
import org.gvsig.app.project.documents.DocumentManager; |
46 |
import org.gvsig.app.project.documents.gui.*; |
47 |
import org.gvsig.tools.ToolsLocator; |
48 |
import org.gvsig.tools.dispose.DisposeUtils; |
49 |
import org.gvsig.tools.i18n.I18nManager; |
50 |
import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
51 |
import org.gvsig.tools.observer.Observable; |
52 |
import org.gvsig.tools.observer.Observer; |
53 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
54 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
55 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
56 |
import org.gvsig.tools.util.Invocable; |
57 |
import org.gvsig.utils.DefaultListModel; |
58 |
import org.slf4j.Logger; |
59 |
import org.slf4j.LoggerFactory; |
60 |
|
61 |
public class ProjectDocumentsPanelPage |
62 |
extends ProjectDocumentsPanelPageView
|
63 |
implements ProjectPanelPage {
|
64 |
|
65 |
private final Logger LOG = LoggerFactory.getLogger(ProjectGeneralPropertiesPage.class); |
66 |
|
67 |
private Project project;
|
68 |
private DocumentManager currentDocumentType;
|
69 |
private final PropertyChangeListener projectPropertyChangeListener; |
70 |
private final Observer projectObserver; |
71 |
|
72 |
public ProjectDocumentsPanelPage() {
|
73 |
this.project = null; |
74 |
this.projectPropertyChangeListener = new PropertyChangeListener() { |
75 |
@Override
|
76 |
public void propertyChange(PropertyChangeEvent evt) { |
77 |
updateProject(); |
78 |
} |
79 |
}; |
80 |
this.projectObserver = new Observer() { |
81 |
@Override
|
82 |
public void update(Observable observable, Object notification) { |
83 |
updateProject(); |
84 |
} |
85 |
}; |
86 |
this.initComponents();
|
87 |
} |
88 |
|
89 |
@Override
|
90 |
public void setData(Object data) { |
91 |
} |
92 |
|
93 |
@Override
|
94 |
public String getTitle() { |
95 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
96 |
return i18n.getTranslation("_Documents"); |
97 |
} |
98 |
|
99 |
@Override
|
100 |
public int getPriority() { |
101 |
return 1000; |
102 |
} |
103 |
|
104 |
@Override
|
105 |
public boolean whenAccept() { |
106 |
return true; |
107 |
} |
108 |
|
109 |
@Override
|
110 |
public boolean whenApply() { |
111 |
return true; |
112 |
} |
113 |
|
114 |
@Override
|
115 |
public boolean whenCancel() { |
116 |
return true; |
117 |
} |
118 |
|
119 |
@Override
|
120 |
public JComponent asJComponent() { |
121 |
return this; |
122 |
} |
123 |
|
124 |
private void initComponents() { |
125 |
this.initDocumentTypes();
|
126 |
this.btnDocumentNew.addActionListener(new ActionListener() { |
127 |
@Override
|
128 |
public void actionPerformed(ActionEvent e) { |
129 |
doDocumentNew(); |
130 |
} |
131 |
}); |
132 |
this.btnDocumentOpen.addActionListener(new ActionListener() { |
133 |
@Override
|
134 |
public void actionPerformed(ActionEvent e) { |
135 |
doDocumentOpen(); |
136 |
} |
137 |
}); |
138 |
this.btnDocumentRename.addActionListener(new ActionListener() { |
139 |
@Override
|
140 |
public void actionPerformed(ActionEvent e) { |
141 |
doDocumentRename(); |
142 |
} |
143 |
}); |
144 |
this.btnDocumentDelete.addActionListener(new ActionListener() { |
145 |
@Override
|
146 |
public void actionPerformed(ActionEvent e) { |
147 |
doDocumentDelete(); |
148 |
} |
149 |
}); |
150 |
this.btnDocumentProperties.addActionListener(new ActionListener() { |
151 |
@Override
|
152 |
public void actionPerformed(ActionEvent e) { |
153 |
doDocumentProperties(); |
154 |
} |
155 |
}); |
156 |
this.btnProjectProperties.addActionListener(new ActionListener() { |
157 |
@Override
|
158 |
public void actionPerformed(ActionEvent e) { |
159 |
doProjectProperties(); |
160 |
} |
161 |
}); |
162 |
this.lstDocuments.addListSelectionListener(new ListSelectionListener() { |
163 |
@Override
|
164 |
public void valueChanged(ListSelectionEvent e) { |
165 |
if (e.getValueIsAdjusting()) {
|
166 |
return;
|
167 |
} |
168 |
doDocumentsSelectionChanged(); |
169 |
} |
170 |
}); |
171 |
this.lstDocuments.addMouseListener(new MouseAdapter() { |
172 |
@Override
|
173 |
public void mouseClicked(MouseEvent e) { |
174 |
if( e.getButton()==MouseEvent.BUTTON1 && e.getClickCount()==2 ) { |
175 |
doDocumentOpen(); |
176 |
} |
177 |
} |
178 |
}); |
179 |
|
180 |
|
181 |
this.lstDocuments.addMouseListener(new java.awt.event.MouseAdapter() { |
182 |
|
183 |
public Document[] getSelecteds() { |
184 |
if (lstDocuments.getSelectedIndex() < 0) { |
185 |
return null; |
186 |
} |
187 |
Object[] seleteds = lstDocuments.getSelectedValues(); |
188 |
Document[] returnValue = new Document[seleteds.length]; |
189 |
System.arraycopy(seleteds, 0, returnValue, 0, |
190 |
seleteds.length); |
191 |
return returnValue;
|
192 |
} |
193 |
|
194 |
public Document getItem(java.awt.event.MouseEvent e) { |
195 |
if (lstDocuments.getSelectedIndex() < 0) { |
196 |
return null; |
197 |
} |
198 |
|
199 |
return (Document) lstDocuments.getSelectedValue(); |
200 |
} |
201 |
|
202 |
@Override
|
203 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
204 |
if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
|
205 |
Document[] selecteds = this.getSelecteds(); |
206 |
Document item = this.getItem(e); |
207 |
if (item == null || ArrayUtils.isEmpty(selecteds)) { |
208 |
return;
|
209 |
} |
210 |
DocumentContextMenu menu |
211 |
= new DocumentContextMenu(
|
212 |
item.getTypeName(), |
213 |
item, |
214 |
selecteds); |
215 |
if (!menu.hasActions()) {
|
216 |
return;
|
217 |
} |
218 |
lstDocuments.add(menu); |
219 |
menu.show(e.getComponent(), e.getX(), e.getY()); |
220 |
return;
|
221 |
} |
222 |
|
223 |
if (e.getClickCount() == 2) { |
224 |
doDocumentOpen(); |
225 |
} |
226 |
|
227 |
} |
228 |
}); |
229 |
|
230 |
this.lstDocuments.setCellRenderer(new DefaultListCellRenderer(){ |
231 |
@Override
|
232 |
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
233 |
JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
234 |
c.setIcon(null);
|
235 |
if(value instanceof Document){ |
236 |
Document doc = (Document) value; |
237 |
if(((Document) value).isTemporary()){ |
238 |
c.setIcon(IconThemeHelper.getImageIcon("temporary-table-icon"));
|
239 |
} |
240 |
} |
241 |
return c;
|
242 |
} |
243 |
}); |
244 |
this.translate();
|
245 |
} |
246 |
|
247 |
private void translate() { |
248 |
ToolsSwingManager manager = ToolsSwingLocator.getToolsSwingManager(); |
249 |
manager.translate(this.lblCreationDate);
|
250 |
manager.translate(this.lblSavedIn);
|
251 |
manager.translate(this.lblSessionName);
|
252 |
manager.translate(this.lblDocument);
|
253 |
manager.translate(this.lblDocumentTypes);
|
254 |
manager.translate(this.lblSessionProperties);
|
255 |
manager.translate(this.lblCreationDate);
|
256 |
manager.translate(this.lblCreationDate);
|
257 |
manager.translate(this.lblCreationDate);
|
258 |
manager.translate(this.lblCreationDate);
|
259 |
manager.translate(this.lblCreationDate);
|
260 |
manager.translate(this.lblCreationDate);
|
261 |
|
262 |
manager.translate(this.btnDocumentDelete);
|
263 |
manager.translate(this.btnDocumentNew);
|
264 |
manager.translate(this.btnDocumentOpen);
|
265 |
manager.translate(this.btnDocumentProperties);
|
266 |
manager.translate(this.btnDocumentRename);
|
267 |
manager.translate(this.btnProjectProperties);
|
268 |
|
269 |
} |
270 |
|
271 |
@Override
|
272 |
public void setProject(Project project) { |
273 |
if( this.project!=null ) { |
274 |
this.project.removePropertyChangeListener(this.projectPropertyChangeListener); |
275 |
this.project.deleteObserver(this.projectObserver); |
276 |
} |
277 |
this.project = project;
|
278 |
if(project!=null){ |
279 |
project.addPropertyChangeListener(this.projectPropertyChangeListener);
|
280 |
project.addObserver(this.projectObserver);
|
281 |
} |
282 |
updateProject(); |
283 |
} |
284 |
|
285 |
private void updateProject() { |
286 |
if( !SwingUtilities.isEventDispatchThread() ) { |
287 |
SwingUtilities.invokeLater(new Runnable() { |
288 |
@Override
|
289 |
public void run() { |
290 |
updateProject(); |
291 |
} |
292 |
}); |
293 |
return;
|
294 |
} |
295 |
updateProjectDocumens(); |
296 |
updateProjectProperties(); |
297 |
} |
298 |
|
299 |
private void updateProjectProperties() { |
300 |
if (project != null) { |
301 |
this.txtSessionName.setText(project.getName());
|
302 |
File path = this.project.getFile(); |
303 |
if (path != null) { |
304 |
this.txtSavedIn.setText(path.toString());
|
305 |
} else {
|
306 |
this.txtSavedIn.setText(""); |
307 |
} |
308 |
this.txtCreationDate.setText(project.getCreationDate());
|
309 |
} |
310 |
} |
311 |
|
312 |
private void initDocumentTypes() { |
313 |
SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
314 |
|
315 |
this.documentTypesContainer.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); |
316 |
|
317 |
List<DocumentManager> factories = ProjectManager.getInstance().getDocumentManagers();
|
318 |
Collections.sort(factories, new Comparator<DocumentManager>() { |
319 |
|
320 |
@Override
|
321 |
public int compare(DocumentManager arg0, DocumentManager arg1) { |
322 |
return arg0.getPriority() - arg1.getPriority();
|
323 |
} |
324 |
|
325 |
}); |
326 |
this.currentDocumentType = factories.get(0); |
327 |
JRadioButton selectButton = null; |
328 |
ButtonGroup group = new ButtonGroup(); |
329 |
JPanel panel = new JPanel(); |
330 |
for (DocumentManager documentFactory : factories) {
|
331 |
if (!identityManager.getCurrentIdentity().isAuthorized(
|
332 |
Document.ACCESS_DOCUMENT_AUTHORIZATION,
|
333 |
documentFactory, |
334 |
documentFactory.getTypeName())) { |
335 |
continue;
|
336 |
} |
337 |
JRadioButton button = this.createDocumentTypeButton(documentFactory); |
338 |
group.add(button); |
339 |
panel.add(button); |
340 |
if( documentFactory == this.currentDocumentType ) { |
341 |
selectButton = button; |
342 |
} |
343 |
} |
344 |
|
345 |
JScrollPane scroll = new JScrollPane(panel); |
346 |
Dimension dim = panel.getPreferredSize();
|
347 |
scroll.setMinimumSize(new Dimension(dim.width+2, dim.height + 35)); |
348 |
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
349 |
scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
350 |
|
351 |
this.documentTypesContainer.setLayout(new BorderLayout()); |
352 |
this.documentTypesContainer.add(scroll, BorderLayout.CENTER); |
353 |
selectButton.setSelected(true);
|
354 |
} |
355 |
|
356 |
private JRadioButton createDocumentTypeButton(final DocumentManager documentFactory) { |
357 |
final JRadioButton rb = new JRadioButton(); |
358 |
|
359 |
rb.setIcon(documentFactory.getIcon()); |
360 |
rb.setSelectedIcon(documentFactory.getIconSelected()); |
361 |
rb.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
362 |
rb.setText(documentFactory.getTitle()); |
363 |
rb.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); |
364 |
rb.setName(documentFactory.getTypeName()); |
365 |
rb.addChangeListener(new javax.swing.event.ChangeListener() {
|
366 |
@Override
|
367 |
public void stateChanged(javax.swing.event.ChangeEvent e) { |
368 |
if (rb.isSelected()) {
|
369 |
currentDocumentType = documentFactory; |
370 |
updateProjectDocumens(); |
371 |
} |
372 |
} |
373 |
}); |
374 |
return rb;
|
375 |
} |
376 |
|
377 |
private void openDocumentWindow(Document doc) { |
378 |
if (doc == null) { |
379 |
return;
|
380 |
} |
381 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
382 |
ApplicationManager application = ApplicationLocator.getManager(); |
383 |
IWindow window = doc.getFactory().getMainWindow(doc); |
384 |
if (window == null) { |
385 |
application.message( |
386 |
i18n.getTranslation("error_opening_the_document"),
|
387 |
JOptionPane.WARNING_MESSAGE
|
388 |
); |
389 |
return;
|
390 |
} |
391 |
application.getUIManager().addWindow( |
392 |
window, |
393 |
MDIManager.ALIGN_FIRST_LINE_END_CASCADE |
394 |
); |
395 |
project.setModified(true);
|
396 |
} |
397 |
|
398 |
private void updateProjectDocumens() { |
399 |
if (project == null) { |
400 |
return;
|
401 |
} |
402 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
403 |
this.lblDocument.setText(i18n.getTranslation("documentos_existentes")); |
404 |
|
405 |
String documentsTypeName = this.currentDocumentType.getTypeName(); |
406 |
List<Document> documents = project.getDocuments(documentsTypeName); |
407 |
DefaultListModel model = new DefaultListModel(documents); |
408 |
this.lstDocuments.setModel(model);
|
409 |
this.lblDocument.setText(currentDocumentType.getTitle());
|
410 |
updateDocumentButtons(); |
411 |
} |
412 |
|
413 |
private void updateDocumentButtons() { |
414 |
this.btnDocumentNew.setEnabled(true); |
415 |
if (this.lstDocuments.getSelectedIndex() != -1) { |
416 |
this.btnDocumentOpen.setEnabled(true); |
417 |
this.btnDocumentDelete.setEnabled(true); |
418 |
this.btnDocumentRename.setEnabled(true); |
419 |
this.btnDocumentProperties.setEnabled(true); |
420 |
} else {
|
421 |
btnDocumentOpen.setEnabled(false);
|
422 |
btnDocumentDelete.setEnabled(false);
|
423 |
btnDocumentRename.setEnabled(false);
|
424 |
btnDocumentProperties.setEnabled(false);
|
425 |
} |
426 |
} |
427 |
|
428 |
private void doDocumentNew() { |
429 |
String documentsTypeName = this.currentDocumentType.getTypeName(); |
430 |
ProjectManager projectManager = ProjectManager.getInstance(); |
431 |
Iterator<? extends Document> documents = projectManager.createDocumentsByUser(documentsTypeName, new Invocable() { |
432 |
@Override
|
433 |
public Object call(Object... args) { |
434 |
Iterator<? extends Document> docs = (Iterator<? extends Document>) args[0]; |
435 |
addNewDocuments(docs); |
436 |
return null; |
437 |
} |
438 |
}); |
439 |
addNewDocuments(documents); |
440 |
} |
441 |
|
442 |
private void addNewDocuments(Iterator<? extends Document> documents) { |
443 |
while ( documents != null && documents.hasNext() ) { |
444 |
Document document = documents.next();
|
445 |
try {
|
446 |
project.addDocument(document); |
447 |
openDocumentWindow(document); |
448 |
} catch (Exception e) { |
449 |
LOG.warn("Can't open document", e);
|
450 |
} finally {
|
451 |
DisposeUtils.disposeQuietly(document); |
452 |
} |
453 |
} |
454 |
this.lstDocuments.requestFocus();
|
455 |
this.lstDocuments.setSelectedIndex(this.lstDocuments.getModel().getSize()-1); |
456 |
} |
457 |
|
458 |
private void doDocumentOpen() { |
459 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
460 |
ApplicationManager application = ApplicationLocator.getManager(); |
461 |
|
462 |
int[] indexes = this.lstDocuments.getSelectedIndices(); |
463 |
for (int i = indexes.length - 1; i >= 0; i--) { |
464 |
int index = indexes[i];
|
465 |
if (index == -1) { |
466 |
return;
|
467 |
} |
468 |
String documentsTypeName = this.currentDocumentType.getTypeName(); |
469 |
List<Document> documents = project.getDocuments(documentsTypeName); |
470 |
Document doc = documents.get(index);
|
471 |
if (!doc.isAvailable()) {
|
472 |
application.messageDialog( |
473 |
i18n.getTranslation("document_not_available"),
|
474 |
i18n.getTranslation("abrir"),
|
475 |
JOptionPane.WARNING_MESSAGE
|
476 |
); |
477 |
} |
478 |
IWindow win = doc.getMainWindow(); |
479 |
openDocumentWindow(doc); |
480 |
} |
481 |
|
482 |
} |
483 |
|
484 |
private void doDocumentRename() { |
485 |
ApplicationManager application = ApplicationLocator.getManager(); |
486 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
487 |
|
488 |
int index = this.lstDocuments.getSelectedIndex(); |
489 |
if (index == -1) { |
490 |
return;
|
491 |
} |
492 |
String DoumentTypeName = this.currentDocumentType.getTypeName(); |
493 |
List<Document> documents = project.getDocuments(DoumentTypeName); |
494 |
Document doc = documents.get(index);
|
495 |
String name = application.inputDialog(
|
496 |
i18n.getTranslation("introduce_nombre"),
|
497 |
i18n.getTranslation("renombrar"),
|
498 |
JOptionPane.QUESTION_MESSAGE,
|
499 |
doc.getName() |
500 |
); |
501 |
if(name != null) { |
502 |
for (Document document : documents) { |
503 |
if (StringUtils.equals(document.getName(), name)) {
|
504 |
application.messageDialog( |
505 |
i18n.getTranslation("elemento_ya_existe"),
|
506 |
i18n.getTranslation("warning"),
|
507 |
JOptionPane.WARNING_MESSAGE
|
508 |
); |
509 |
return;
|
510 |
} |
511 |
} |
512 |
doc.setName(name); |
513 |
updateProjectDocumens(); |
514 |
this.project.setModified(true); |
515 |
} |
516 |
} |
517 |
|
518 |
private void doDocumentDelete() { |
519 |
ApplicationManager application = ApplicationLocator.getManager(); |
520 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
521 |
|
522 |
int res = application.confirmDialog(
|
523 |
i18n.getTranslation("confirmar_borrar"),
|
524 |
i18n.getTranslation("borrar"),
|
525 |
JOptionPane.YES_NO_OPTION,
|
526 |
JOptionPane.INFORMATION_MESSAGE,
|
527 |
"Confirm remove document from project"
|
528 |
); |
529 |
int lastremoved = 0; |
530 |
if (res == JOptionPane.YES_OPTION) { |
531 |
String DoumentTypeName = this.currentDocumentType.getTypeName(); |
532 |
int[] indexes = this.lstDocuments.getSelectedIndices(); |
533 |
for (int i = indexes.length - 1; i >= 0; i--) { |
534 |
int index = indexes[i];
|
535 |
List<Document> documents = project.getDocuments(DoumentTypeName); |
536 |
Document doc = documents.get(index);
|
537 |
if (doc.isLocked()) {
|
538 |
application.messageDialog( |
539 |
i18n.getTranslation("locked_element_it_cannot_be_deleted"),
|
540 |
i18n.getTranslation("Information"),
|
541 |
JOptionPane.INFORMATION_MESSAGE
|
542 |
); |
543 |
return;
|
544 |
} |
545 |
PluginServices.getMDIManager().closeSingletonWindow(doc); |
546 |
project.removeDocument(doc); |
547 |
lastremoved = index; |
548 |
} |
549 |
if (lastremoved >= this.lstDocuments.getModel().getSize()) { |
550 |
this.lstDocuments.setSelectedIndex(this.lstDocuments.getModel().getSize() - 1); |
551 |
} else if (lastremoved >= 0) { |
552 |
this.lstDocuments.setSelectedIndex(lastremoved);
|
553 |
} |
554 |
project.setModified(true);
|
555 |
} |
556 |
|
557 |
} |
558 |
|
559 |
private void doDocumentProperties() { |
560 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
561 |
ApplicationManager application = ApplicationLocator.getManager(); |
562 |
|
563 |
int index = this.lstDocuments.getSelectedIndex(); |
564 |
if (index == -1) { |
565 |
return;
|
566 |
} |
567 |
String DoumentTypeName = this.currentDocumentType.getTypeName(); |
568 |
List<Document> documents = project.getDocuments(DoumentTypeName); |
569 |
Document doc = documents.get(index);
|
570 |
if (!doc.isAvailable()) {
|
571 |
application.messageDialog( |
572 |
i18nManager.getTranslation("document_not_available"),
|
573 |
i18nManager.getTranslation("properties"),
|
574 |
JOptionPane.WARNING_MESSAGE
|
575 |
); |
576 |
return;
|
577 |
} |
578 |
IWindow properties = doc.getFactory().getPropertiesWindow(doc); |
579 |
application.getUIManager().addWindow( |
580 |
properties |
581 |
); |
582 |
this.lstDocuments.setSelectedIndex(index);
|
583 |
project.setModified(true);
|
584 |
} |
585 |
|
586 |
private void doProjectProperties() { |
587 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
588 |
WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
589 |
ProjectProperties panel = new ProjectProperties(project);
|
590 |
panel.addComponentListener(new ComponentAdapter() { |
591 |
@Override
|
592 |
public void componentHidden(ComponentEvent e) { |
593 |
updateProjectProperties(); |
594 |
} |
595 |
}); |
596 |
winmgr.showWindow( |
597 |
panel, |
598 |
i18nManager.getTranslation("project_properties"),
|
599 |
WindowManager.MODE.WINDOW |
600 |
); |
601 |
} |
602 |
|
603 |
private void doDocumentsSelectionChanged() { |
604 |
this.updateDocumentButtons();
|
605 |
} |
606 |
} |