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