01: /*
02: * Project: AMODA - Abstract Modeled Application
03: * Class: de.gulden.framework.amoda.environment.gui.GUIRecentFilesList
04: * Version: snapshot-beautyj-1.1
05: *
06: * Date: 2004-09-29
07: *
08: * This is a snapshot version of the AMODA 0.2 development branch,
09: * it is not released as a seperate version.
10: * For AMODA, see http://amoda.berlios.de/.
11: *
12: * This is licensed under the GNU Lesser General Public License (LGPL)
13: * and comes with NO WARRANTY.
14: *
15: * Author: Jens Gulden
16: * Email: amoda@jensgulden.de
17: */
18:
19: package de.gulden.framework.amoda.environment.gui;
20:
21: import de.gulden.framework.amoda.environment.commandline.*;
22: import de.gulden.framework.amoda.generic.core.GenericRecentFilesList;
23: import java.util.*;
24:
25: /**
26: * Class GUIRecentFilesList.
27: *
28: * @author Jens Gulden
29: * @version snapshot-beautyj-1.1
30: */
31: public class GUIRecentFilesList extends GenericRecentFilesList {
32:
33: // ------------------------------------------------------------------------
34: // --- field ---
35: // ------------------------------------------------------------------------
36:
37: protected int previousMenuEntriesCount = 0;
38:
39: // ------------------------------------------------------------------------
40: // --- method ---
41: // ------------------------------------------------------------------------
42:
43: public void hasBeenChanged() {
44: super .hasBeenChanged();
45: javax.swing.JMenu menu = ((GUIApplicationEnvironment) application
46: .getEnvironment()).getFileMenu();
47: java.awt.Component[] components = menu.getMenuComponents();
48: if (previousMenuEntriesCount > 0) {
49: for (int i = components.length - 1; i > components.length
50: - previousMenuEntriesCount - 2; i--) { // remove all including separator
51: menu.remove(components[i]);
52: }
53: }
54: if (size() > 0) {
55: menu.addSeparator();
56: for (int i = 0; i < size(); i++) {
57: Object entry = this .get(i);
58: String label = String.valueOf(i + 1) + " ";
59: de.gulden.framework.amoda.generic.behaviour.GenericCommand command = null;
60: if (entry instanceof java.io.File) {
61: java.io.File file = (java.io.File) entry;
62: label += file.getPath();
63: command = new de.gulden.framework.amoda.environment.gui.behaviour.CommandOpenRecentFileListEntry(
64: file);
65: } else if (entry instanceof java.net.URL) {
66: java.net.URL url = (java.net.URL) entry;
67: label += url.toExternalForm();
68: command = new de.gulden.framework.amoda.environment.gui.behaviour.CommandOpenRecentFileListEntry(
69: url);
70: }
71: command.setParent(application);
72: javax.swing.JMenuItem item = new javax.swing.JMenuItem(
73: label);
74: item.addActionListener(command);
75: menu.add(item);
76: }
77: previousMenuEntriesCount = size();
78: }
79: }
80:
81: } // end GUIRecentFilesList
|