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